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.proj.tasker.dao.impl.CartaoCredDAO.java

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

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

@Override
public void deletarEndereco(Endereco end) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//from w w  w. j  a va2 s  .co m
        session.getTransaction().begin();
        session.delete(end);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao deletar: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

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

@Override
public void deletarPessoa(Pessoa pessoa) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*w  w w .  ja v a  2s.  co m*/
        session.getTransaction().begin();
        session.delete(pessoa);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao deletar: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

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

@Override
public void deletarTelefone(Telefone tel) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from  www  . j  av a 2  s.  co  m*/
        session.getTransaction().begin();
        session.delete(tel);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao Deletar: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

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

@Override
public void deletarUsuario(Usuario usuario) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from  w  w w . j  ava2s  .  c om*/
        session.getTransaction().begin();
        session.delete(usuario);
        session.getTransaction().commit();
    } catch (Exception e) {
        System.out.println("Erro ao deletar: " + e.getMessage());
        session.getTransaction().rollback();
    }
}

From source file:br.com.projetoweb.model.dao.LivroDAOImp.java

public void remove(Livro livro) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.delete(livro);
    t.commit();/*from   w w w  .ja  v a2  s  . c o  m*/
}

From source file:br.com.pucminas.debt.dao.impl.ProjetoDAOImpl.java

@Override
public void excluir(Projeto projeto) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = null;// w w w  .j a  va 2 s .c  o  m
    try {
        t = session.beginTransaction();
        session.delete(projeto);
        session.getTransaction().commit();
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, new FacesMessage("Projeto " + projeto.getNome(), "Excludo com sucesso!"));
    } catch (HibernateException e) {
        if (t != null) {
            t.rollback();
        }
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro!",
                "No foi possvel excluir o projeto: " + e));
    } finally {
        session.close();
    }
}

From source file:br.com.railsos.os.dao.GenericDAO.java

/**
 * Metdo excluir Exclui variaveis do banco
 *
 * @author Rafael//  w  w  w  .j a v  a2s .c o m
 */
public void excluir(Entidade entidade) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Transaction transacao = null;

    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.rhmanager.daoImpl.HibernateDAO.java

public void excluir(Object obj) throws Exception {
    Session session = null;
    Transaction transaction = null;// w  ww  .ja  va2 s.c o m

    try {
        session = HibernateUtil.getSession();
        transaction = session.beginTransaction();
        session.delete(obj);
        session.flush();
        transaction.commit();

    } finally {
        session.close();
    }
}

From source file:br.com.sescacre.controleAcesso.dao.CargosDAO.java

public void excluir(Cargos cargo) {
    Session s = HibernateUtil.getSession();
    Transaction t = s.beginTransaction();
    s.delete(cargo);
    t.commit();
    s.close();
}