List of usage examples for org.hibernate Session update
void update(Object object);
From source file:cd_modelos_dao.ProveedoresDAO.java
public Proveedores actualizarproveedor(int cedula, String nombre, String apellido, String telefono, String correo) {/*ww w . j a va2s.com*/ SessionFactory sf = HibernateUtil.getSessionFactory(); try { Session s = sf.openSession(); Transaction t = s.beginTransaction(); Proveedores u = new Proveedores(cedula, nombre, apellido, telefono, correo); s.update(u); t.commit(); s.close(); return u; } catch (HibernateException he) { he.printStackTrace(); } return null; }
From source file:cd_modelos_dao.ServiciosDAO.java
public Servicios actualizarServicio(int id, String nombre, String descripcion, int costo) { SessionFactory sf = HibernateUtil.getSessionFactory(); try {// w ww .ja v a 2s. c om Session s = sf.openSession(); Transaction t = s.beginTransaction(); Servicios u = new Servicios(); u.setNombre(nombre); u.setDescripcion(descripcion); s.update(u); t.commit(); s.close(); return u; } catch (HibernateException he) { he.printStackTrace(); } return null; }
From source file:cd_modelos_dao.VentasDAO.java
public void actualizarVenta(VentasPlanta v1, VentasPlanta v2) { SessionFactory sf = HibernateUtil.getSessionFactory(); //Listas/*from w ww .j a va 2 s . co m*/ List<PlantasVenta> a1 = new LinkedList<>(v1.getPlantasVentas()); List<PlantasVenta> a2 = new LinkedList<>(v2.getPlantasVentas()); try { Session s = sf.openSession(); Transaction t = s.beginTransaction(); s.update(v2); System.out.println("la cantidad de lineas de enta es"); System.out.println(v2.getPlantasVentas().size()); for (PlantasVenta plantasVenta : v2.getPlantasVentas()) { try { EtapasPlantaDAO eD = new EtapasPlantaDAO(); eD.ingresarActualizarEtapasPlanta(plantasVenta.getEtapasPlanta()); } catch (Exception e) { System.out.println("1"); System.out.println(e); } try { PlantasVentaDAO pvd = new PlantasVentaDAO(); if (plantasVenta.getId() < 0) { plantasVenta.setId(pvd.maxId() + 1); } pvd.ingresarPlantasVenta(plantasVenta); } catch (Exception e) { System.out.println("2"); System.out.println(e); } } insertarDiferenciasVentasPlanta(calcularDiferenciasVentasPlanta(v1, v2)); insertarDiferenciasPlantasVenta(calcularDiferenciasPlantasVenta(a1, a2)); t.commit(); s.close(); } catch (HibernateException he) { System.out.println("Paso algo 1"); System.out.println(he); he.getMessage(); } }
From source file:ch.qos.logback.audit.persistent.Persistor.java
License:Open Source License
protected static void update(Object o) throws HibernateException { Session s = null; Transaction tx = null;/*from w w w .j a v a2s .c o m*/ try { s = openSession(); tx = s.beginTransaction(); s.update(o); tx.commit(); } catch (HibernateException he) { if (tx != null) { tx.rollback(); } throw he; } finally { close(s, tx); } }
From source file:ch.tatool.app.service.impl.ModuleDAO.java
License:Open Source License
public void addModuleProperties(final ModuleImpl impl, final Map<String, String> properties) { getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) { session.update(impl); Map<String, String> props = impl.getModuleProperties(); for (String key : props.keySet()) { logger.debug(key + ": " + props.get(key)); }//w ww .j a v a 2s. co m for (String key : properties.keySet()) { String value = properties.get(key); props.put(key, value); } session.save(impl); return null; } }); }
From source file:chitchatserver.UserDAO.java
public static boolean updateUser(User user) { if (getUser(user.getId()) == null) { return false; }/*from www . ja va 2 s . c o m*/ Session session = HibernateUtil.getSessionFactory().openSession(); try { Transaction transaction = session.beginTransaction(); session.update(user); transaction.commit(); } catch (Exception ex) { System.out.println(ex.getMessage()); } finally { session.close(); } return true; }
From source file:cit360.hibernate.hibernateDemo.java
private static void updateSoda(Integer SodaId, String field, String value) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;/*from www .ja v a 2 s .co m*/ Soda soda = getSoda(SodaId); switch (field) { case "name": soda.setName(value); break; case "flavor": soda.setFlavor(value); break; case "color": soda.setColor(value); break; } try { tx = session.beginTransaction(); session.update(soda); tx.commit(); } catch (HibernateException e) { if (tx != null) tx.rollback(); e.printStackTrace(); } finally { session.close(); } }
From source file:cl.cesfam.DAO.CaducarDAO.java
public static boolean update(cl.cesfam.ENTITY.Caducar a) throws Exception { Session session = cl.cesfam.DAL.NewHibernateUtil.getSessionFactory().openSession(); session.beginTransaction();// ww w . j a v a 2 s .c om try { session.update(a); session.getTransaction().commit(); session.close(); return true; } catch (Exception e) { session.getTransaction().rollback(); session.close(); System.err.println(e.getMessage()); throw e; } }
From source file:cl.cesfam.DAO.ComponenteDAO.java
public static boolean update(cl.cesfam.ENTITY.Componente a) throws Exception { Session session = cl.cesfam.DAL.NewHibernateUtil.getSessionFactory().openSession(); session.beginTransaction();// w w w . j av a2 s . c o m try { session.update(a); session.getTransaction().commit(); session.close(); return true; } catch (Exception e) { session.getTransaction().rollback(); session.close(); System.err.println(e.getMessage()); throw e; } }
From source file:cl.cesfam.DAO.ComposicionDAO.java
public static boolean update(cl.cesfam.ENTITY.Composicion a) throws Exception { Session session = cl.cesfam.DAL.NewHibernateUtil.getSessionFactory().openSession(); session.beginTransaction();/*from www . j a v a 2 s .c om*/ try { session.update(a); session.getTransaction().commit(); session.close(); return true; } catch (Exception e) { session.getTransaction().rollback(); session.close(); System.err.println(e.getMessage()); throw e; } }