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.ufmt.fata.dao.SujeitoDaoImp.java

@Override
public void remove(Sujeito sujeito) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.delete(sujeito);
    t.commit();/*from   w  w  w . ja v a 2 s . c  o  m*/
    session.close();
}

From source file:br.com.ufmt.fata.dao.VerboDaoImp.java

@Override
public void remove(Verbo verbo) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    session.delete(verbo);
    t.commit();/*from w  w  w .java  2s .co  m*/
    session.close();
}

From source file:br.crescer.aula04.entity.dao.GenericDAO.java

@Override
public void remove(long id) {
    Session s = em.unwrap(Session.class);

    T t = listById(id);//  w ww . j a  v a 2s.  c o m
    s.delete(t);

    // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

From source file:br.edu.ifes.bd2hibernate.cgd.DAO.java

public void deletar(int id, Class c) {
    Session s = HibernateUtil.getSession();
    HibernateUtil.begin();/*from  w  w w . ja va  2s.  c om*/

    Object o = c.cast(s.load(c, new Integer(id)));
    s.delete(c.cast(o));

    HibernateUtil.commit();
    HibernateUtil.close();
}

From source file:br.edu.ifes.bd2hibernate.cgd.DAO.java

public void deletar(Object obj, Class c) {
    Session s = HibernateUtil.getSession();
    HibernateUtil.begin();//  w ww.j a va2s  .c o  m

    s.delete(c.cast(obj));

    HibernateUtil.commit();
    HibernateUtil.close();
}

From source file:br.edu.ifsp.dsw.dao.impl.TagDAOImpl.java

@Override
public void removerTag(Long id) {
    Session session = this.sessionFactory.getCurrentSession();
    Tag tag = (Tag) session.load(Tag.class, id);
    if (null != tag) {
        session.delete(tag);
    }//w  ww.j a v  a  2  s .com
    logger.info("Tag removida com sucesso, detalhes=" + tag);
}

From source file:br.edu.ifsp.dsw.dao.impl.UsuarioDAOImpl.java

@Override
public void removerUsuario(Integer id) {
    Session session = this.sessionFactory.getCurrentSession();
    Usuario usuario = (Usuario) session.load(Usuario.class, id);
    if (null != usuario) {
        session.delete(usuario);
    }//from   w  w w  .  java  2  s. c  o m
    logger.info("Usuario removido com sucesso, detalhes=" + usuario);
}

From source file:br.edu.unipampa.gerenciadorconcurso.dao.DAO.java

public static boolean excluir(int codigo, Class type) {
    Session session = HibernateUtil.openSession();
    Transaction tx = null;/* w  w w.  ja v a2s  . co m*/
    try {
        tx = session.getTransaction();
        tx.begin();
        Object object = session.get(type, codigo);
        session.delete(object);
        tx.commit();

    } catch (Exception e) {
        if (tx != null) {
            tx.rollback();
        }
        session.close();
        return false;
    } finally {
        session.close();
    }
    return true;
}

From source file:br.mdarte.exemplo.academico.cd.CursoDAO.java

public List<AbstractEntity> delete(AbstractEntity obj) throws DAOException {
    try {/*w w  w  . jav a 2s .c om*/
        Session session = currentSession();
        removeRelations(obj);
        session.delete(obj);
        session.flush();
        return null;
    } catch (HibernateException e) {
        throw new DAOException(e);
    }
}

From source file:br.msf.commons.persistence.dao.AbstractEntityDaoBean.java

License:Open Source License

@Override
public void delete(final T entity) {
    ArgumentUtils.rejectIfNull(entity);//w  w w  . j a  va  2 s. com
    final Session session = getCurrentSession();
    if (entity.getId() != null) {
        session.delete(entity);
        entity.setId(null);
    }
}