List of usage examples for org.hibernate Session load
void load(Object object, Serializable id);
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.Catalogos.java
public String deletById(int idEmpleado) { Session hibernateSession; hibernateSession = HibernateUtil.getSessionFactory().openSession(); Transaction t = hibernateSession.beginTransaction(); Empleado Empleado = (Empleado) hibernateSession.load(Empleado.class, idEmpleado); hibernateSession.delete(Empleado);/*from w w w . j a v a2s. c o m*/ t.commit(); hibernateSession.close(); return "Empleados"; }
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.Empleados.java
public Empleado showById(int id) { Session hibernateSession = HibernateUtil.getSessionFactory().openSession(); Transaction t0 = hibernateSession.beginTransaction(); Empleado empleado = (Empleado) hibernateSession.load(Empleado.class, id); hibernateSession.update(empleado);// w w w.ja v a2 s . c o m t0.commit(); hibernateSession.close(); return empleado; }
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.Empleados.java
public void update(int id) { Session hibernateSession = HibernateUtil.getSessionFactory().openSession(); Transaction t0 = hibernateSession.beginTransaction(); Empleado empleado = (Empleado) hibernateSession.load(Empleado.class, id); empleado.setRolempleado(getRol(idRol)); empleado.setEstadoempleado(getEdo(idEdo)); hibernateSession.update(getRol(idRol)); hibernateSession.update(getEdo(idEdo)); hibernateSession.update(empleado);//from w w w . j a va 2 s . com hibernateSession.getTransaction().commit(); hibernateSession.close(); }
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.Empleados.java
public Estadoempleado getEdo(int idEdo) { Session hibernateSession; hibernateSession = HibernateUtil.getSessionFactory().openSession(); hibernateSession.beginTransaction(); Estadoempleado edo = (Estadoempleado) hibernateSession.load(Estadoempleado.class, idEdo); hibernateSession.getTransaction().commit(); hibernateSession.close();/*from w ww . j a v a 2 s.c om*/ return edo; }
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.Empleados.java
public Rolempleado getRol(int idRol) { Session hibernateSession; hibernateSession = HibernateUtil.getSessionFactory().openSession(); Transaction t = hibernateSession.beginTransaction(); Rolempleado edo = (Rolempleado) hibernateSession.load(Rolempleado.class, idRol); t.commit();/*from ww w. jav a2 s . co m*/ hibernateSession.close(); return edo; }
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.Empleados.java
public Contacto getCont(int idCon) { Session hibernateSession; hibernateSession = HibernateUtil.getSessionFactory().openSession(); Transaction t = hibernateSession.beginTransaction(); Contacto edo = (Contacto) hibernateSession.load(Contacto.class, idCon); t.commit();//from www.j a v a 2 s. c o m hibernateSession.close(); return edo; }
From source file:com.ipn.mx.escom.biblioteca.ManagedBeans.TTs.java
private String actualizarInstanciaTt() { Tt tt1 = new Tt(); tt1.setNoTt(noTt);//from ww w . j a v a2 s. c om /* tt1.setTitulo(titulo); tt1.setFechaPresent(fechaPresent); tt1.setAutor1(autor1); tt1.setAutor2(autor2); tt1.setAutor3(autor3); tt1.setAutor4(autor4); tt1.setAutor5(autor5); tt1.setDirector1(director1); tt1.setDirector2(director2); // borrado S/N = 1/0 estadoBorrado = 0; tt1.setEstadoBorrado(estadoBorrado); */ Session hibernateSession = HibernateUtil.getSessionFactory().openSession(); Transaction t0 = hibernateSession.beginTransaction(); tt = (Tt) hibernateSession.load(Tt.class, tt1.getNoTt()); tt.setTitulo(titulo); tt.setFechaPresent(fechaPresent); tt.setAutor1(autor1); tt.setAutor2(autor2); tt.setAutor3(autor3); tt.setAutor4(autor4); tt.setAutor5(autor5); tt.setDirector1(director1); tt.setDirector2(director2); if (borrar) { tt.setEstadoBorrado(1); } else { tt.setEstadoBorrado(0); } try { hibernateSession.update(tt); hibernateSession.getTransaction().commit(); hibernateSession.close(); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "OK", "Se modific exitosamente el TT")); clearValues(); return "ConsultarTTMod"; } catch (HibernateException e) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Error!", "No se pudo modificar el TT")); return "ModificarEliminarTt"; } }
From source file:com.it355.filip.dao.impl.BrandDaoImpl.java
@Override public Brand getBrandByID(int id) { Session session = this.sessionFactory.getCurrentSession(); Brand brand = (Brand) session.load(Brand.class, new Integer(id)); //logger.info("Person loaded successfully, Person details=" + p); return brand; /*String sql = "SELECT * FROM brand WHERE brand_ID =" + id; List<Brand> brands = jdbcTemplate.query(sql, new BrandMapper()); return brands;*//*from w ww . ja v a 2s . c om*/ }
From source file:com.it355.filip.dao.impl.BrandDaoImpl.java
@Override public boolean removeBrand(int id) { Session session = this.sessionFactory.getCurrentSession(); Brand b = (Brand) session.load(Brand.class, new Integer(id)); if (null != b) { session.delete(b);/*from www . j av a 2 s . co m*/ return true; } else { return false; } //logger.info("Person deleted successfully, person details=" + p); /*String sql = "DELETE FROM brand WHERE name= " + name; jdbcTemplate.update(sql); return true;*/ }
From source file:com.it355.filip.dao.impl.DisplayDaoImpl.java
@Override public Display getDisplayByID(int id) { Session session = this.sessionFactory.getCurrentSession(); Display display = (Display) session.load(Display.class, new Integer(id)); //logger.info("Person loaded successfully, Person details=" + p); return display; /*String sql = "SELECT * FROM display WHERE brand_ID =" + id; List<Display> displays = jdbcTemplate.query(sql, new DisplayMapper()); return displays;*/// ww w. jav a2s . co m }