List of usage examples for org.hibernate Session flush
void flush() throws HibernateException;
From source file:cn.lhfei.airqa.dao.support.Hibernate4DaoSupport.java
License:Apache License
public void batchInsert(List<E> list) { Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for (int i = 0; i < list.size(); i++) { session.save(list.get(i));//from www . ja v a2 s. c om if (i % 50 == 0) { //50, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close(); }
From source file:cn.sharek.bsg.machine.dao.impl.DMLDaoImpl.java
@Override public void save(Collection<T> entities, Session session) throws Exception { int i = 0;//w w w .ja va 2s .c o m //??? for (Object obj : entities) { session.save(obj); i++; //?? if (0 == i % 10) { session.flush();//? session.clear();// } } }
From source file:cn.sharek.bsg.machine.dao.impl.DMLDaoImpl.java
@Override public void delete(Collection<T> entities, Session session) throws Exception { int i = 0;//from w w w. j a va2s . c om //??? for (Object obj : entities) { session.delete(obj); i++; //?? if (0 == i % 10) { session.flush();//? session.clear();// } } }
From source file:co.com.ordersAgiles.controlador.OrdprfDaoImplements.java
@Override public List<Ordprf> listar() { System.out.println("listando de bd"); List<Ordprf> lista = null; try {// w w w . j a va2 s . c o m Session sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion = NewHibernateUtil.getSessionFactory().openSession(); Query q = sesion.createQuery("from Ordprf order by id"); lista = (List<Ordprf>) q.list(); sesion.flush(); if (sesion != null) { sesion.close(); } } catch (Exception e) { System.out.println("MENSAGE : " + e.getMessage()); } return lista; }
From source file:co.com.ordersAgiles.controlador.OrdprfDaoImplements.java
@Override public void insertar(Ordprf perfil) { System.out.println("Insertando en bd"); Session sesion = null; try {/*from w ww . j a v a 2s.c o m*/ sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); sesion.save(perfil); sesion.getTransaction().commit(); sesion.flush(); } catch (Exception e) { System.out.println("mensaje:" + e.getMessage()); sesion.getTransaction().rollback(); } finally { if (sesion != null) { sesion.close(); } } }
From source file:co.com.ordersAgiles.controlador.OrdprfDaoImplements.java
@Override public void modificar(Ordprf perfil) { System.out.println("Modificando en bd"); Session sesion = null; try {//from w ww . j ava 2 s . c om sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); sesion.update(perfil); sesion.getTransaction().commit(); sesion.flush(); } catch (Exception e) { System.out.println("mensaje:" + e.getMessage()); sesion.getTransaction().rollback(); } finally { if (sesion != null) { sesion.close(); } } }
From source file:co.com.ordersAgiles.controlador.OrdprfDaoImplements.java
@Override public void eliminar(Ordprf perfil) { System.out.println("Eliminando en bd"); Session sesion = null; try {// w w w . j av a 2 s . c om sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); sesion.delete(perfil); sesion.getTransaction().commit(); sesion.flush(); } catch (Exception e) { System.out.println("mensaje:" + e.getMessage()); sesion.getTransaction().rollback(); } finally { if (sesion != null) { sesion.close(); } } }
From source file:co.com.ordersAgiles.controlador.OrdprmDaoImplements.java
@Override public List<Ordprm> listar() { System.out.println("listando de bd"); List<Ordprm> lista = null; try {//w w w . ja va 2 s.co m Session sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion = NewHibernateUtil.getSessionFactory().openSession(); Query q = sesion.createQuery("from Ordprm order by id"); lista = (List<Ordprm>) q.list(); sesion.flush(); if (sesion != null) { sesion.close(); } } catch (Exception e) { System.out.println("MENSAGE : " + e.getMessage()); } return lista; }
From source file:co.com.ordersAgiles.controlador.OrdprmDaoImplements.java
@Override public void insertar(Ordprm permiso) { System.out.println("Insertando en bd"); Session sesion = null; try {//from ww w . j a v a 2s . co m sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); sesion.save(permiso); sesion.getTransaction().commit(); sesion.flush(); } catch (Exception e) { System.out.println("mensaje:" + e.getMessage()); sesion.getTransaction().rollback(); } finally { if (sesion != null) { sesion.close(); } } }
From source file:co.com.ordersAgiles.controlador.OrdprmDaoImplements.java
@Override public void modificar(Ordprm permiso) { System.out.println("Modificando en bd"); Session sesion = null; try {//from ww w. j a va 2 s . c o m sesion = NewHibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); sesion.update(permiso); sesion.getTransaction().commit(); sesion.flush(); } catch (Exception e) { System.out.println("mensaje:" + e.getMessage()); sesion.getTransaction().rollback(); } finally { if (sesion != null) { sesion.close(); } } }