List of usage examples for org.hibernate Session delete
void delete(Object object);
From source file:br.com.livraria.dao.VendaDAO.java
public void excluir(Venda venda) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = null;/*from w w w. j av a2 s.c o m*/ try { transacao = sessao.beginTransaction(); sessao.delete(venda); transacao.commit(); } catch (RuntimeException ex) { if (transacao != null) { transacao.rollback(); } throw ex; } finally { sessao.close(); } }
From source file:br.com.ln.dao.GenericDao.java
/** * * @param obj delete object/* w w w .j a v a 2 s . co m*/ * @param strDbName */ public static void deleteObject(Object obj) { Session session = null; Transaction tx; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); session.delete(obj); tx.commit(); } catch (HibernateException ex) { logger.error("Problemas no delete : " + ex.getMessage()); } finally { if (session != null && session.isOpen()) { session.close(); } } }
From source file:br.com.ln.hibernate.Postgress.java
/** * * @param obj delete object/*ww w .ja va 2 s .c o m*/ * @param strDbName */ public static void deleteObject(Object obj) { Session session = null; Transaction tx; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); session.delete(obj); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } }
From source file:br.com.lsi.ordemservico.dao.DAOGeneric.java
@Override public void deletar(T t) throws DAOException { Session sessao = PersistenceUtil.getSessionFactory().openSession(); try {//w w w. ja v a2 s. co m sessao.getTransaction().begin(); sessao.delete(t); sessao.getTransaction().commit(); } catch (Exception e) { sessao.getTransaction().rollback(); e.printStackTrace(); throw new DAOException("Erro ao Deletar no BD"); } finally { sessao.close(); } }
From source file:br.com.mandado.dao.BairroDAO.java
/** * @param bairro//from www . j a v a 2 s. c o m */ public void excluir(Bairro bairro) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = null; try { transacao = sessao.beginTransaction(); sessao.delete(bairro); transacao.commit(); } catch (RuntimeException ex) { if (transacao != null) { transacao.rollback(); } throw ex; } finally { sessao.close(); } }
From source file:br.com.mandado.dao.MandadoDAO.java
/** * @param mandado//from www . j a v a 2 s. c o m */ public void excluir(Mandado mandado) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = null; try { transacao = sessao.beginTransaction(); sessao.delete(mandado); transacao.commit(); } catch (RuntimeException ex) { if (transacao != null) { transacao.rollback(); } throw ex; } finally { sessao.close(); } }
From source file:br.com.moises.dao.Dao.java
@Override public boolean remove(T entity) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); try {//www .j a v a 2 s . co m session.getTransaction().begin(); session.delete(entity); session.getTransaction().commit(); FacesUtil.addInfoMessage("Removido com sucesso!!"); return true; } catch (Exception e) { session.getTransaction().rollback(); FacesUtil.addInfoMessage("Erro ao remover!!!" + e); return false; } }
From source file:br.com.nfsconsultoria.nfsuporte.dao.GenericDAO.java
public void excluir(Entidade entidade) { Session sessao = HibernateUtil.getFabricaDeSessoes().openSession(); Transaction transacao = null;/* w ww .j a v a2 s . c o m*/ try { transacao = sessao.beginTransaction(); sessao.delete(entidade); transacao.commit(); } catch (RuntimeException erro) { if (transacao != null) { transacao.rollback(); } throw erro; } finally { sessao.close(); } }
From source file:br.com.nfsconsultoria.radiologic.dao.GenericDAO.java
public void excluir(Entidade entidade) { Session sessao = HBUtil.getSessionFactory().openSession(); Transaction transacao = null;// w w w . j a va 2 s .com try { transacao = sessao.beginTransaction(); sessao.delete(entidade); transacao.commit(); } catch (RuntimeException ex) { if (transacao != null) { transacao.rollback(); } throw ex; } finally { sessao.close(); } }
From source file:br.com.proj.tasker.dao.impl.AtivacaoDAO.java
@Override public void delAtivacao(Ativacao ativ) { Session session = HibernateUtil.getSessionFactory().openSession(); try {//from w ww .ja v a2s . c o m session.getTransaction().begin(); session.delete(ativ); session.getTransaction().commit(); } catch (Exception e) { System.out.println("Erro ao deletar: " + e.getMessage()); session.getTransaction().rollback(); } }