Example usage for org.hibernate Session delete

List of usage examples for org.hibernate Session delete

Introduction

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

Prototype

void delete(Object object);

Source Link

Document

Remove a persistent instance from the datastore.

Usage

From source file:br.com.batcommerce.dao.AdministradorDAO.java

public void excluir(Administrador administrador) {
    Session sessao = conexao.openSession();
    Transaction transacao = sessao.beginTransaction();

    sessao.delete(administrador);
    transacao.commit();//from w  ww .  ja va  2s.co m
    sessao.close();

}

From source file:br.com.batcommerce.dao.ProdutoDAO.java

public void excluir(Produto produto) {
    Session sessao = conexao.openSession();
    Transaction transacao = sessao.beginTransaction();

    sessao.delete(produto);
    transacao.commit();/*w  ww  . j  a  va  2  s. c  o  m*/
    sessao.close();

}

From source file:br.com.bibliotecasj.DAO.FrequenciaDAO.java

@Override
public void deletar(String fre) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//w w  w  .  j a v a2s  .com

    try {
        transacao = sessao.beginTransaction();
        Frequencia frequencia = buscar(fre);
        sessao.delete(frequencia);
        sessao.getTransaction().commit();

    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
    } finally {
        sessao.close();
    }
}

From source file:br.com.bibliotecasj.DAO.LoginDAO.java

@Override
public void deletar(String log) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;/*from   w w w. j  ava 2  s. c om*/

    try {
        transacao = sessao.beginTransaction();
        Login login = buscar(log);
        sessao.delete(login);
        sessao.getTransaction().commit();

    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
    } finally {
        sessao.close();
    }
}

From source file:br.com.bibliotecasj.DAO.UsuarioDAO.java

@Override
public void deletar(String usu) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;//from   www  .  j  a  va2 s. c  om

    try {
        transacao = sessao.beginTransaction();
        Usuario usuario = buscar(usu);
        sessao.delete(usuario);
        sessao.getTransaction().commit();

    } catch (RuntimeException ex) {
        if (transacao != null) {
            transacao.rollback();
        }
    } finally {
        sessao.close();
    }
}

From source file:br.com.chamado.dao.DaoGenerico.java

public void deletar(Object obj) {
    Session session = hibernateConfiguracao.openSession();
    Transaction transaction = session.beginTransaction();
    session.delete(obj);
    transaction.commit();/*from  www.  j av  a  2 s .co  m*/
    session.close();
}

From source file:br.com.clinica.dao.ConsultaDao.java

public void remover(Consulta consulta) {
    Session ss = HibernateUtil.getSessionFactory().getCurrentSession();
    ss.beginTransaction();/*from   w w w .  ja  v  a2  s .  co  m*/
    ss.delete(consulta);
    ss.getTransaction().commit();
    //ss.close();
}

From source file:br.com.clinica.dao.DadosAdicionaisDao.java

@Override
public void remover(DadosAdicionais dadosAdicionais) {
    Session ss = HibernateUtil.getSessionFactory().getCurrentSession();
    ss.beginTransaction();//ww  w . j  a va  2  s  .co  m
    ss.delete(dadosAdicionais);
    ss.getTransaction().commit();
    ss.close();
}

From source file:br.com.clinica.dao.PessoaDao.java

@Override
public void remover(Pessoa pessoa) {
    Session ss = HibernateUtil.getSessionFactory().getCurrentSession();

    try {//from  w w  w  . j a v  a  2  s.  c om
        ss.beginTransaction();
        try {
            ss.delete(pessoa);
            ss.getTransaction().commit();
        } catch (Exception ex) {
            // Log the exception here
            ss.getTransaction().rollback();
            throw ex;
        }
    } finally {
        HibernateUtil.getSessionFactory().getCurrentSession().close();

    }
}

From source file:br.com.clinica.dao.ProntuarioDao.java

@Override
public void remover(Prontuario prontuario) {
    Session ss = HibernateUtil.getSessionFactory().getCurrentSession();

    try {//w ww.  j a  v  a 2  s . c  om
        System.out.println("Entoru Try");
        ss.beginTransaction();
        try {
            System.out.println("Entoru delete");
            ss.delete(prontuario);
            System.out.println("Entoru Commit");
            ss.getTransaction().commit();
        } catch (Exception ex) {
            // Log the exception here
            ss.getTransaction().rollback();
            throw ex;
        }
    } finally {
        HibernateUtil.getSessionFactory().getCurrentSession().close();

    }
}