List of usage examples for org.hibernate Session saveOrUpdate
void saveOrUpdate(Object object);
From source file:com.iqtb.validacion.dao.DaoRolesOpciones.java
@Override public boolean insertRolesOpciones(RolesHasOpciones rolesOpciones) throws Exception { boolean insert = false; Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); try {/* w w w .ja v a2s. co m*/ session.saveOrUpdate(rolesOpciones); tx.commit(); insert = true; } catch (HibernateException he) { logger.error("insertRolesOpciones ERROR: " + he); tx.rollback(); } finally { if (session.isOpen()) { session.close(); } } return insert; }
From source file:com.iqtb.validacion.dao.DaoServicio.java
@Override public boolean updateServicio(Servicios servicio) throws Exception { boolean update = false; Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); try {//from w ww . j av a 2 s .c om session.saveOrUpdate(servicio); tx.commit(); update = true; } catch (HibernateException he) { logger.error("updateServicio - ERROR: " + he); tx.rollback(); // session.getTransaction().rollback(); } finally { if (session.isOpen()) { session.close(); } } return update; }
From source file:com.itseekers.sistemaplandeproduccion.dao.impl.UsuarioDaoImpl.java
@Transactional public int insertUsuario(UsuarioDto usuarioDto) { Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); session.saveOrUpdate(usuarioDto); tx.commit();/*w w w.j av a 2s. co m*/ Serializable id = session.getIdentifier(usuarioDto); session.close(); return (Integer) id; }
From source file:com.javaweb.service.ChuyenbayService.java
public boolean InsertChuyenbay(Chuyenbay cb) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;//ww w . j av a 2 s .c o m try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(cb); tx.commit(); return true; } catch (Exception e) { if (tx != null) { tx.rollback(); } System.out.println(e.toString()); } finally { session.close(); } return false; }
From source file:com.javaweb.service.NguoidungService.java
public boolean InsertNguoidung(Nguoidung nd) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;//w ww . j av a 2s. com try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(nd); tx.commit(); return true; } catch (Exception e) { if (tx != null) { tx.rollback(); } System.out.println(e.toString()); } finally { session.close(); } return false; }
From source file:com.javaweb.service.SanPhamService.java
public boolean InsertSanpham(Sanpham sp) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;//from w w w .j a v a 2s. c om try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(sp); tx.commit(); return true; } catch (Exception e) { if (tx != null) { tx.rollback(); } System.out.println(e.toString()); } finally { session.close(); } return false; }
From source file:com.javaweb.service.TaikhoanService.java
public boolean InsertTaikhoan(Taikhoan tk) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;/* w w w. j av a 2s.c o m*/ try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(tk); tx.commit(); return true; } catch (Exception e) { if (tx != null) { tx.rollback(); } System.out.println(e.toString()); } finally { session.close(); } return false; }
From source file:com.javaweb.service.TintucService.java
public boolean InsertTintuc(Tintuc tt) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;/*from w ww .j ava2 s . co m*/ try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(tt); tx.commit(); return true; } catch (Exception e) { if (tx != null) { tx.rollback(); } System.out.println(e.toString()); } finally { session.close(); } return false; }
From source file:com.javaweb.service.UserService.java
public boolean InsertUser(Users user) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;/*from w w w. j av a2 s . c om*/ try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(user); tx.commit(); return true; } catch (Exception e) { if (tx != null) { tx.rollback(); } System.out.println(e.toString()); } finally { session.close(); } return false; }
From source file:com.javaweb.service.UserServices.java
public static boolean InsertOrUpdate(TbUsers user) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = null;/*from w w w .j av a2 s . c om*/ try { tx = session.getTransaction(); tx.begin(); session.saveOrUpdate(user); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } else { System.out.println("ERRORMSG: " + e.getMessage()); } return false; } finally { session.close(); } return true; }