Example usage for org.hibernate Session save

List of usage examples for org.hibernate Session save

Introduction

In this page you can find the example usage for org.hibernate Session save.

Prototype

Serializable save(Object object);

Source Link

Document

Persist the given transient instance, first assigning a generated identifier.

Usage

From source file:br.com.nfsconsultoria.radiologic.dao.GenericDAO.java

public void salvar(Entidade entidade) {

    Session sessao = HBUtil.getSessionFactory().openSession();
    Transaction transacao = null;//from  w  w  w .j  av  a2s.c om

    try {
        transacao = sessao.beginTransaction();
        sessao.save(entidade);
        transacao.commit();
    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
        throw ex;
    } finally {
        sessao.close();
    }
}

From source file:br.com.patrimonio.model.dao.BemMovelDao.java

public void inserirBemMovel(BemMovel bemMovel) {
    Session session;
    session = conexao.openSession();/*from  www  .j a  v  a 2s  .  c o m*/
    Transaction tx = session.beginTransaction();
    session.save(bemMovel);
    tx.commit();
    session.close();
}

From source file:br.com.patrimonio.model.dao.GenericDao.java

public void inserir(T o) {
    Session session;
    session = conexao.openSession();// ww  w. j a v  a 2s. c om
    Transaction tx = session.beginTransaction();
    session.save(o);
    tx.commit();
    session.close();
}

From source file:br.com.patrimonio.model.dao.TipoIncorporacaoDao.java

public void inserirTipoIncorporacao(TipoIncorporacao tipoIncorporacao) {
    Session session;
    session = conexao.openSession();/* w  ww  . ja va  2s  .  com*/
    Transaction tx = session.beginTransaction();
    session.save(tipoIncorporacao);
    tx.commit();
    session.close();
}

From source file:br.com.proj.tasker.dao.impl.AtivacaoDAO.java

@Override
public void confAtivacao(Ativacao ativ) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//from   ww  w . j  a va  2s  .c  o  m
        session.getTransaction().begin();
        session.save(ativ);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Inserir: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.proj.tasker.dao.impl.AtivMembrosDAO.java

@Override
public void regGrupo(Ativmembros am) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*  w ww.  ja v  a 2  s  . c om*/
        session.getTransaction().begin();
        session.save(am);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Inserir: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.proj.tasker.dao.impl.CargoDAO.java

@Override
public void inserirCargo(Cargo cargo) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//from   w ww .j a v a2s . com
        session.getTransaction().begin();
        session.save(cargo);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Inserir: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.proj.tasker.dao.impl.CartaoCredDAO.java

@Override
public void inserirCartaoCred(Cartaocred card) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from   w ww.j a  v a  2  s. co m*/
        session.getTransaction().begin();
        session.save(card);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Inserir: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.proj.tasker.dao.impl.EnderecoDAO.java

@Override
public void inserirEndereco(Endereco end) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from w ww  .  ja v a2 s  . c  o  m*/
        session.getTransaction().begin();
        session.save(end);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Inserir: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.proj.tasker.dao.impl.GrupoDAO.java

@Override
public void inserirGrupo(Grupo grupo) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {// w w w  .  j a v a  2  s.  c  o m
        session.getTransaction().begin();
        session.save(grupo);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Inserir: " + e.getMessage());
        session.getTransaction().rollback();
    }
}