List of usage examples for org.hibernate SessionFactory close
void close() throws HibernateException;
From source file:mx.uach.service.WpWoocommerceOrderItemsServiceImp.java
@Override public List<WpWoocommerceOrderItems> getAll() { SessionFactory sf = HibernateSession.getSessionFactory(); Session s = sf.openSession();//from ww w . jav a 2 s . co m List<WpWoocommerceOrderItems> pedido = s.createQuery("from WpWoocommerceOrderItems").list(); s.close(); sf.close(); return pedido; }
From source file:mx.uach.service.WpWoocommerceOrderItemsServiceImp.java
@Override public Integer agregarPedido(WpWoocommerceOrderItems p) { SessionFactory sf = HibernateSession.getSessionFactory(); Session session = sf.openSession();// w w w. ja v a2 s . co m Transaction t = session.beginTransaction(); Integer success = (Integer) session.save(p); t.commit(); session.close(); sf.close(); return success; }
From source file:mypack.Datainsert.java
public static int reg(Students s) { int i = 0;//w w w . ja va 2 s . c o m // Session session=new Configuration().configure().buildSessionFactory().openSession(); SessionFactory factory = new Configuration().configure().buildSessionFactory(); Session session = factory.openSession(); Transaction t = session.beginTransaction(); //t.begin(); i = (Integer) session.save(s); t.commit(); session.close(); factory.close(); return i; }
From source file:net.krotscheck.jersey2.hibernate.factory.HibernateSessionFactoryFactory.java
License:Apache License
/** * Dispose of the hibernate session./* w ww . java2 s . c o m*/ * * @param sessionFactory The session to dispose. */ @Override public void dispose(final SessionFactory sessionFactory) { if (sessionFactory != null && !sessionFactory.isClosed()) { logger.info("Disposing of hibernate session factory."); sessionFactory.close(); } }
From source file:nl.intercommit.weaves.hibernate.SessionFactorySourceImpl.java
License:Open Source License
public void registryDidShutdown() { for (final SessionFactory sessionFactory : symbolMap.values()) { sessionFactory.close(); }//from ww w . j a va 2s . co m }
From source file:openones.oopms.daocommon.DefectAddDao.java
License:Apache License
/** * [Give the description for method]./* ww w.j av a 2s .c om*/ * @param defect a * @return true */ public boolean insertDefect(Defect defect) { SessionFactory sessfac = HibernateUtil.getSessionFactory(); sess = sessfac.openSession(); tx = sess.beginTransaction(); sess.save(defect); tx.commit(); sessfac.close(); return true; }
From source file:openones.oopms.daocommon.DeveloperDao.java
License:Apache License
/** * Save Developer instance./*w w w . j ava 2s . c o m*/ * @param dev DeveloperId will be get next value. * @return true of success */ public final boolean insertDeveloper(Developer dev) { try { SessionFactory sessFact = HibernateUtil.getSessionFactory(); sess = sessFact.openSession(); Transaction tx = sess.beginTransaction(); // Get max id // Query query = sess.createQuery(SQL_MAX_DEV_ID); String sql = "SELECT DEVELOPER_SEQ.NEXTVAL as nextValue FROM dual"; Query query = sess.createSQLQuery(sql).addScalar("nextValue", Hibernate.BIG_DECIMAL); BigDecimal nextId = (BigDecimal) query.list().get(0); // Update next id dev.setDeveloperId(nextId); // Uppercase Account dev.setAccount(dev.getAccount().toUpperCase()); // Set BeginDate as default if null if (dev.getBeginDate() == null) { dev.setBeginDate(new Date()); } sess.save(dev); tx.commit(); sessFact.close(); return true; } catch (RuntimeException rEx) { log.error("Saving Developer...", rEx); return false; } }
From source file:openones.oopms.daocommon.QcActivityDao.java
License:Apache License
/** * [Give the description for method]./* ww w . j av a2s . c om*/ * @param qcAc a * @return a */ public boolean insertQcActivity(QcActivity qcAc) { SessionFactory sessfac = HibernateUtil.getSessionFactory(); sess = sessfac.openSession(); tx = sess.beginTransaction(); sess.save(qcAc); tx.commit(); sessfac.close(); return true; }
From source file:openones.oopms.daocommon.QcActivityDao.java
License:Apache License
/** * [Give the description for method].// w ww . ja v a 2 s . co m * @param qcAc a * @return a */ public boolean deleteQcActivity(QcActivity qcAc) { SessionFactory sessfac = HibernateUtil.getSessionFactory(); sess = sessfac.openSession(); tx = sess.beginTransaction(); sess.delete(qcAc); tx.commit(); sessfac.close(); return true; }
From source file:openones.oopms.daocommon.QcActivityDao.java
License:Apache License
/** * [Give the description for method].//from w w w . j av a 2s. c o m * @param qcAc a * @return a */ public boolean updateQcActivity(QcActivity qcAc) { SessionFactory sessfac = HibernateUtil.getSessionFactory(); sess = sessfac.openSession(); tx = sess.beginTransaction(); sess.update(qcAc); tx.commit(); sessfac.close(); return true; }