List of usage examples for org.hibernate Session flush
void flush() throws HibernateException;
From source file:br.com.rhmanager.daoImpl.HibernateDAO.java
public void insert(Object obj) throws Exception { Session session = null; Transaction transaction = null;// w w w . j a v a 2s . c o m try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); session.save(obj); session.flush(); transaction.commit(); } finally { session.close(); } }
From source file:br.com.rhmanager.daoImpl.HibernateDAO.java
@Transactional public void update(Object obj) throws Exception { Session session = null; Transaction transaction = null;//w w w. j av a 2 s .c om try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); session.update(obj); session.flush(); transaction.commit(); } finally { session.close(); } }
From source file:br.com.rhmanager.daoImpl.HibernateDAO.java
public void excluir(Object obj) throws Exception { Session session = null; Transaction transaction = null;//from w w w. jav a 2s . c om try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); session.delete(obj); session.flush(); transaction.commit(); } finally { session.close(); } }
From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> insert(AbstractEntity obj) throws DAOException { List<AbstractEntity> lista = new ArrayList<AbstractEntity>(); try {/*ww w .j a v a2s . c o m*/ Session session = currentSession(); session.setCacheMode(CacheMode.GET); session.save(obj); session.flush(); lista.add(obj); return lista; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> insertOrUpdate(AbstractEntity obj) throws DAOException { List<AbstractEntity> lista = new ArrayList<AbstractEntity>(); try {// w w w . ja v a2s. co m Session session = currentSession(); session.setCacheMode(CacheMode.GET); session.saveOrUpdate(obj); session.flush(); lista.add(obj); return lista; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> update(AbstractEntity obj) throws DAOException { List<AbstractEntity> lista = new ArrayList<AbstractEntity>(); try {/*from www . j a va 2s . c o m*/ Session session = currentSession(); session.setCacheMode(CacheMode.GET); session.update(obj); session.flush(); lista.add(obj); return lista; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java
public List<AbstractEntity> delete(AbstractEntity obj) throws DAOException { try {//from w w w . j a va 2s .c o m Session session = currentSession(); removeRelations(obj); session.delete(obj); session.flush(); return null; } catch (HibernateException e) { throw new DAOException(e); } }
From source file:br.msf.commons.persistence.dao.AbstractEntityDaoBean.java
License:Open Source License
@Override public void flush() { final Session session = getCurrentSession(); session.flush(); session.clear(); }
From source file:br.pro.x87.dao.MaquinaDao.java
public void updateMaquina(Maquina maquina) { Session session = null; try {// ww w .j a v a 2 s. c o m session = HibernateConnector.getInstance().getSession(); session.saveOrUpdate(maquina); session.flush(); } catch (Exception e) { e.printStackTrace(); } finally { session.close(); } }
From source file:br.ufg.calendario.dao.CalendarioDao.java
private void disableOthers(Session session, Calendario calendario) { Criteria criteria = session.createCriteria(Calendario.class); List<Calendario> calendarioList = criteria.list(); int counter = 0; for (Calendario c : calendarioList) { if (!Objects.equals(c.getId(), calendario.getId())) { c.setAtivo(false);/* w w w .j a va 2 s . c om*/ session.save(c); } if (++counter % 20 == 0) { session.flush(); session.clear(); } } }