List of usage examples for org.hibernate Session saveOrUpdate
void saveOrUpdate(Object object);
From source file:com.inventory.system.dao.StaffDAOImpl.java
@Override public Teacher register(Teacher teacher) { Session session = HibernateBDUtil.getSessionFactory().openSession(); Transaction tx = null;// ww w . j a v a 2 s . c o m try { tx = session.beginTransaction(); session.saveOrUpdate(teacher); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); ex.printStackTrace(); } } finally { session.close(); } return teacher; }
From source file:com.inventory.system.dao.StaffDAOImpl.java
@Override public NonTeachingStaff addNonTeachingStaff(NonTeachingStaff nts) { Session session = HibernateBDUtil.getSessionFactory().openSession(); Transaction tx = null;/*from w w w .ja v a 2s . c o m*/ try { tx = session.beginTransaction(); session.saveOrUpdate(nts); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); ex.printStackTrace(); } } finally { session.close(); } return nts; }
From source file:com.inventory.system.dao.StateDAOImpl.java
@Override public State addState(State state) { Session session = HibernateBDUtil.getSessionFactory().openSession(); Transaction tx = null;/* w w w . jav a2 s .com*/ try { tx = session.beginTransaction(); session.saveOrUpdate(state); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); ex.printStackTrace(); } } finally { session.close(); } return state; }
From source file:com.inventory.system.dao.StudentRegistrationDAOImpl.java
@Override public StudentRegistration register(StudentRegistration student) { Session session = HibernateBDUtil.getSessionFactory().openSession(); Transaction tx = null;/* w w w. j a va2s . com*/ try { tx = session.beginTransaction(); session.saveOrUpdate(student); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); ex.printStackTrace(); } } finally { session.close(); } return student; }
From source file:com.ipn.dao.UsuarioDAO.java
public void crearActualizarUsuario(Usuario usuario) throws HibernateException { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Transaction transaction = session.getTransaction(); try {//from www . j a v a2s . c o m // Empieza la transaccion, guarda o actualiza al usuario transaction.begin(); session.saveOrUpdate(usuario); transaction.commit(); } catch (HibernateException e) { if (transaction != null && transaction.isActive()) transaction.rollback(); } }
From source file:com.ipn.dao.UsuarioDAO.java
public void crearActualizarArchivo(Archivo archivo) throws Exception { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); Transaction transaction = session.getTransaction(); try {/*w w w . j a v a 2 s . c o m*/ // Empieza la transaccion, guarda o actualiza al usuario transaction.begin(); session.saveOrUpdate(archivo); transaction.commit(); } catch (HibernateException e) { if (transaction != null && transaction.isActive()) transaction.rollback(); } }
From source file:com.iqtb.validacion.dao.DaoCfdisRecibidos.java
@Override public Boolean actualizarCfdi(CfdisRecibidos cfdi) throws Exception { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); try {// w w w .ja v a2 s .c o m session.saveOrUpdate(cfdi); tx.commit(); return true; } catch (HibernateException e) { logger.error("Ocurrio un error al actualizar el Cfdi: " + e); tx.rollback(); } finally { if (session.isOpen()) { session.close(); } } return false; }
From source file:com.iqtb.validacion.dao.DaoConectorAdaptador.java
@Override public boolean updateConectorAdaptador(ConectorAdaptador conectorAdaptador) throws Exception { boolean update = false; Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); try {//from ww w .ja v a2s . c o m session.saveOrUpdate(conectorAdaptador); tx.commit(); update = true; } catch (HibernateException he) { logger.error("updateConectorAdaptador ERROR: " + he); tx.rollback(); } finally { if (session.isOpen()) { session.close(); } } return update; }
From source file:com.iqtb.validacion.dao.DaoConfiguracionServicios.java
@Override public boolean updateConfigServicios(ConfiguracionesServicios configServicios) throws Exception { boolean update = false; Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); try {/* ww w. ja v a 2 s . c o m*/ session.saveOrUpdate(configServicios); tx.commit(); update = true; } catch (HibernateException he) { logger.error("Error al modificar Configuraciones Servicios. ERROR: " + he); tx.rollback(); } finally { if (session.isOpen()) { session.close(); } } return update; }
From source file:com.iqtb.validacion.dao.DaoEmpresa.java
@Override public boolean updateEmpresa(Empresas empresa) throws Exception { boolean update = false; Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); try {//from w w w .j a v a 2 s . c om session.saveOrUpdate(empresa); tx.commit(); update = true; } catch (HibernateException he) { logger.error("updateEmpresa ERROR: " + he); tx.rollback(); } finally { if (session.isOpen()) { session.close(); } } return update; }