List of usage examples for org.hibernate Session save
Serializable save(Object object);
From source file:br.com.foogames.database.dao.hibernateDAO.java
public static void insert(Object obj) { Session openSession = HibernateUtil.getSessionFactory().openSession(); openSession.save(obj); openSession.flush();/*from w ww. ja v a2s.c o m*/ openSession.close(); }
From source file:br.com.gaiatosfc.DAO.AdversariosDAOImp.java
@Override public void salvar(Adversarios jogador) throws DAOException { Session session = null; try {//from ww w . j a v a 2 s .c o m session = HibernateUtil.getSessionFactory().openSession(); Transaction t = session.beginTransaction(); session.save(jogador); t.commit(); } catch (Exception e) { session.getTransaction().rollback(); throw new DAOException(e); } finally { if (session != null) { session.close(); } } }
From source file:br.com.gaiatosfc.DAO.CampeonatosDAOImp.java
@Override public void salvar(Campeonatos campeonato) throws DAOException { Session session = null; try {//from www. ja v a 2s .c o m session = HibernateUtil.getSessionFactory().openSession(); Transaction t = session.beginTransaction(); session.save(campeonato); t.commit(); } catch (Exception e) { session.getTransaction().rollback(); throw new DAOException(e); } finally { if (session != null) { session.close(); } } }
From source file:br.com.gaiatosfc.DAO.JogadoresDAOImp.java
@Override public void salvar(Jogadores jogador) throws DAOException { Session session = null; try {/*from w ww . j av a2 s . co m*/ session = HibernateUtil.getSessionFactory().openSession(); Transaction t = session.beginTransaction(); session.save(jogador); t.commit(); session.flush(); session.clear(); } catch (Exception e) { session.getTransaction().rollback(); throw new DAOException(e); } finally { if (session != null) { session.close(); } } }
From source file:br.com.gesteduc.administrador.AdministradorDao.java
public void salvar(Administrador administrador) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction t = session.beginTransaction(); session.save(administrador); t.commit();/*from ww w. j ava 2 s. co m*/ }
From source file:br.com.hslife.sirce.hibernate.GerarTabelas.java
License:Open Source License
public static void main(String[] args) { GerarTabelas.geraTabelas();/*w w w. ja v a 2 s .c o m*/ // Realiza o cadastro do usurio administrador Login l = new Login(); l.setAtivo(true); l.setDataCriacao(new Date()); l.setNomeUsuario("Administrador do Sistema"); l.setPerfil("ADMIN"); l.setUsuarioLogin("admin"); l.setUsuarioSenha(Util.SHA1("admin123")); Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = sessao.beginTransaction(); sessao.save(l); transacao.commit(); sessao.close(); }
From source file:br.com.jn.dao.CandidatoDAO.java
public Boolean adicionar(Candidato candidato) { try {/*from ww w .ja v a 2 s . c o m*/ Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(candidato); session.getTransaction().commit(); session.close(); return true; } catch (HibernateException e) { System.out.println(e.toString()); return false; } }
From source file:br.com.jn.dao.UsersDAO.java
public Boolean adicionar(Users users) { try {/* www . j a v a 2 s.com*/ Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(users); session.getTransaction().commit(); session.close(); return true; } catch (HibernateException e) { System.out.println(e.toString()); return false; } }
From source file:br.com.jvmsoftware.daos.PubPosicaoDAO.java
public void inserirPosicao(PubPosicao pos) throws SQLException { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();// www .j a v a 2 s. co m session.save(pos); session.flush(); session.beginTransaction().commit(); session.close(); }
From source file:br.com.livraria.dao.AutorDAO.java
public void salvar(Autor autor) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = null;//from ww w . j a v a 2 s . c om try { transacao = sessao.beginTransaction(); sessao.save(autor); transacao.commit(); } catch (RuntimeException ex) { if (transacao != null) { transacao.rollback(); } throw ex; } finally { sessao.close(); } }