Example usage for javax.persistence EntityManager remove

List of usage examples for javax.persistence EntityManager remove

Introduction

In this page you can find the example usage for javax.persistence EntityManager remove.

Prototype

public void remove(Object entity);

Source Link

Document

Remove the entity instance.

Usage

From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.SessionRecordingDaoImpl.java

@Override
@Transactional//from  ww w .  ja  v  a 2 s  .  c  o  m
public void deleteRecording(SessionRecording recording) {
    final SessionRecordingImpl sessionRecording = this.getSessionRecording(recording.getRecordingId());

    //Remove the reference from the session to the recording
    final SessionImpl session = sessionRecording.getSession();
    session.getSessionRecordings().remove(sessionRecording);

    final EntityManager entityManager = this.getEntityManager();
    entityManager.remove(sessionRecording);
    entityManager.persist(session);
}

From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.SessionTelephonyDaoImpl.java

@Override
@Transactional//from w w  w  .j  a  v a2  s  .  c o  m
public void deleteTelephony(long sessionId) {
    final SessionImpl session = sessionDao.getSession(sessionId);
    final SessionTelephonyImpl sessionTelephony = DataAccessUtils.singleResult(session.getSessionTelephony());

    //Remove the reference from the session to the recording

    session.getSessionTelephony().remove(sessionTelephony);

    final EntityManager entityManager = this.getEntityManager();
    entityManager.remove(sessionTelephony);
    entityManager.persist(session);
}

From source file:org.croodie.resource.UserServerResource.java

@Delete
public Representation deleteUser(Representation entity) {
    Form form = new Form(entity);
    String id = form.getFirstValue("id");
    EntityManagerFactory emf = EMF.get();
    EntityManager em = emf.createEntityManager();
    try {//from  w w  w .  ja va2s  .  c om
        User user = em.find(User.class, id);
        em.remove(user);
    } finally {
        em.close();
    }
    return null;
}

From source file:vn.edu.vnuk.tasks_jpa.dao.TaskDao.java

public void delete(Long id) throws SQLException {

    Task task = this.read(id);

    EntityManager manager = getEntityManager();
    manager.getTransaction().begin();/*from   ww  w  . jav a2 s  .c om*/
    task = manager.merge(task);
    manager.remove(task);
    manager.getTransaction().commit();
    manager.close();

}

From source file:nl.b3p.viewer.admin.stripes.CycloramaConfigurationActionBean.java

public Resolution removeKey() {
    EntityManager em = Stripersist.getEntityManager();
    em.remove(account);
    em.getTransaction().commit();/*from   w w  w .  jav  a2s  . com*/
    account = new CycloramaAccount();
    this.context.getMessages().add(
            new SimpleMessage(getBundle().getString("viewer_admin.cycloramaconfigurationactionbean.keyrem")));
    return view();
}

From source file:com.appdynamics.loan.persistence.BasePersistenceImpl.java

@Transactional
public void delete(Serializable object) {
    EntityManager entityManager = getEntityManager();
    EntityTransaction txn = entityManager.getTransaction();
    txn.begin();// w  w  w . j a  v  a  2 s .c  o  m
    try {
        entityManager.remove(object);
    } catch (Exception ex) {
        txn.rollback();
    } finally {
        if (!txn.getRollbackOnly()) {
            txn.commit();
        }
    }
}

From source file:com.webbfontaine.valuewebb.action.tt.TtLogger.java

public String deleteUserLog(TtLog log) {
    EntityManager entityManager = null;
    try {/*from  ww w  .java 2  s.  co m*/
        entityManager = Utils.createEntityManager();
        entityManager.remove(entityManager.merge(log));
        entityManager.flush();

        reloadLogs(log);
    } finally {
        if (entityManager != null) {
            entityManager.close();
        }
    }
    return "";
}

From source file:com.soen.ebanking.dao.ObjectDao.java

public void deleteObject(Object object, long id, Class<T> ClassName) {
    EntityManager em = this.getEMF().createEntityManager();
    try {//from w  w w.j  ava 2 s.  c  o m
        em.getTransaction().begin();
        T entity = em.find(ClassName, id);
        em.remove(entity);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}

From source file:com.sun.socialsite.business.impl.JPAPersistenceStrategy.java

/**
 * Remove object from persistence storage.
 * @param po the persistent object to remove
 * @throws SocialSiteException on any error
 *//* w ww . ja  va 2s.  c  o  m*/
public void remove(Object po) throws SocialSiteException {
    EntityManager em = getEntityManager(true);
    em.remove(po);
}

From source file:com.appdynamicspilot.persistence.BasePersistenceImpl.java

@Transactional
public void delete(Serializable object) {
    EntityManager entityManager = getEntityManager();
    EntityTransaction txn = entityManager.getTransaction();
    txn.begin();//from ww  w  .j av  a 2 s. c  o m
    try {
        entityManager.remove(object);
    } catch (Exception ex) {
        logger.error(ex);
        txn.rollback();
    } finally {
        if (!txn.getRollbackOnly()) {
            txn.commit();
        }
    }
}