List of usage examples for org.hibernate Session save
Serializable save(Object object);
From source file:br.com.railsos.os.dao.GenericDAO.java
/** * Mtodo Genrico Salvar Adiciona valores ao banco * * @author Rafael//w w w .ja v a 2 s. co m */ public void salvar(Entidade entidade) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = null; try { transacao = sessao.beginTransaction(); sessao.save(entidade); transacao.commit(); } catch (RuntimeException erro) { if (transacao != null) { transacao.rollback(); } throw erro; } finally { sessao.close(); } }
From source file:br.com.rhmanager.daoImpl.HibernateDAO.java
public void insert(Object obj) throws Exception { Session session = null; Transaction transaction = null;//ww w. j a v a 2 s .co m try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); session.save(obj); session.flush(); transaction.commit(); } finally { session.close(); } }
From source file:br.com.sescacre.controleAcesso.dao.CargosDAO.java
public void salvar(Cargos cargo) throws Exception { Session s = HibernateUtil.getSession(); try {//from w ww. j av a 2 s. c o m Transaction t = s.beginTransaction(); s.save(cargo); t.commit(); } catch (Exception ex) { throw new SQLIntegrityConstraintViolationException(); } finally { s.close(); } }
From source file:br.com.sescacre.controleAcesso.dao.CategoriasDao.java
public void salvar(Categorias cat) throws Exception { Session s = HibernateUtil.getSession(); try {/*from ww w . j a v a 2 s .c o m*/ Transaction t = s.beginTransaction(); s.save(cat); t.commit(); } catch (Exception ex) { throw new SQLIntegrityConstraintViolationException(); } finally { s.close(); } }