List of usage examples for org.hibernate Session clear
void clear();
From source file:com.sap.data.db.dao.EventDao.java
public void save(List<EventPojo> evnts) throws NotFoundException { Session session = null; try {/*from w w w.ja va2 s . c o m*/ session = HibernateUtil.getSession(); session.beginTransaction(); for (EventPojo evnt : evnts) { session.saveOrUpdate("EventPojo", evnt); session.flush(); session.clear(); } session.getTransaction().commit(); } catch (HibernateException ex) { session.getTransaction().rollback(); Logger.getLogger(EventDao.class.getName()).log(Level.SEVERE, null, ex); throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } }
From source file:com.sap.data.db.dao.StructureDao.java
public void saveEntityToList(List<?> entities) throws NotFoundException { synchronized (lock) { Session session = null; try {/*from ww w . j av a 2s. c o m*/ if (entities != null) { session = HibernateUtil.getSession(); session.beginTransaction(); int i = 0; for (Object entity : entities) { session.saveOrUpdate(this.structure, entity); if (i++ % 20 == 0) { session.flush(); session.clear(); } } session.getTransaction().commit(); } } catch (HibernateException ex) { if (session != null) { session.getTransaction().rollback(); } throw new NotFoundException(ex.getMessage()); } finally { HibernateUtil.close(session); } } }
From source file:com.sasav.blackjack.dao.AccountDao.java
public boolean runAccountTransaction(Account account, AccountTransaction transaction) { Session session = sessionFactory.openSession(); Transaction tx = null;/* www . j a v a 2 s . c o m*/ try { tx = session.beginTransaction(); session.saveOrUpdate(transaction); session.saveOrUpdate(account); session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } LOG.error("Saving AccountTransaction with error ", e); return false; } return true; }
From source file:com.sasav.blackjack.dao.AccountDao.java
public boolean runAccountTransaction(Account account, Account account2, AccountTransaction transaction) { Session session = sessionFactory.openSession(); Transaction tx = null;/* ww w .ja v a2 s .c o m*/ try { tx = session.beginTransaction(); session.saveOrUpdate(transaction); session.saveOrUpdate(account); session.saveOrUpdate(account2); session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } LOG.error("Saving AccountTransaction with error ", e); return false; } return true; }
From source file:com.sasav.blackjack.dao.CommonDao.java
public boolean saveOrUpdate(Object object) { Session session = sessionFactory.openSession(); Transaction tx = null;/*from w ww.ja v a2s. co m*/ try { tx = session.beginTransaction(); session.saveOrUpdate(object); session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } LOG.error("Saving with error ", e); return false; } return true; }
From source file:com.sasav.blackjack.dao.CommonDao.java
public boolean savaOrUpdateAll(Collection coll) { Session session = sessionFactory.openSession(); Transaction tx = null;// w w w .j a v a 2s .c o m try { tx = session.beginTransaction(); for (Iterator it = coll.iterator(); it.hasNext();) { session.saveOrUpdate(it.next()); } session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } LOG.error("Saving with error ", e); return false; } return true; }
From source file:com.sasav.blackjack.dao.CommonDao.java
public void delete(Object object) { Session session = sessionFactory.openSession(); Transaction tx = null;/*from w w w .j a v a 2 s.com*/ try { tx = session.beginTransaction(); session.delete(object); session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } }
From source file:com.sasav.blackjack.dao.CommonDao.java
public void deleteAll(Collection coll) { Session session = sessionFactory.openSession(); Transaction tx = null;/*from w ww.j av a 2 s . c o m*/ try { tx = session.beginTransaction(); for (Iterator it = coll.iterator(); it.hasNext();) { session.delete(it.next()); } session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } }
From source file:com.sasav.blackjack.dao.CommonDao.java
public void runQuery(String queryS) { Session session = sessionFactory.openSession(); Transaction tx = null;//from www. j a v a 2s . c o m try { tx = session.beginTransaction(); Query query = session.createSQLQuery(queryS); query.executeUpdate(); session.flush(); session.clear(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } }
From source file:com.sigaf.dao.EmpleadoAreaDao.java
@Override public void update(TEmpleadoArea empleadoArea) { Session session = sessionFactory.openSession(); session.beginTransaction();/*w ww . j ava 2 s.c o m*/ session.update(empleadoArea); session.getTransaction().commit(); session.clear(); session.close(); }