Example usage for javax.persistence EntityTransaction commit

List of usage examples for javax.persistence EntityTransaction commit

Introduction

In this page you can find the example usage for javax.persistence EntityTransaction commit.

Prototype

public void commit();

Source Link

Document

Commit the current resource transaction, writing any unflushed changes to the database.

Usage

From source file:eu.forgestore.ws.impl.FStoreJpaController.java

public void saveUser(FStoreUser bu) {
    logger.info("Will save FStoreUser = " + bu.getName());

    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();//from   w  w  w .  j  av a 2  s . c om

    entityManager.persist(bu);
    //      List<ApplicationMetadata> apps = bu.getApps();
    //      for (ApplicationMetadata app : apps) {         
    //         entityManager.persist(app.getCategory());
    //         entityManager.persist(app);
    //      }
    //      
    //      List<BunMetadata> buns = bu.getBuns() ;
    //      for (BunMetadata bun : buns) {         
    //         entityManager.persist(bun.getCategory());
    //         entityManager.persist(bun);
    //      }

    entityManager.flush();
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteProperty(int propid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();
    PortalProperty c = entityManager.find(PortalProperty.class, propid);

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();//from w  w w  . j  a v  a  2s.  co  m
    entityManager.remove(c);
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteMANOplatform(int mpid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();
    MANOplatform c = entityManager.find(MANOplatform.class, mpid);

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();/*from w w  w .  j  a v  a 2 s  .c o  m*/
    entityManager.remove(c);
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteMANOprovider(int mpid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();
    MANOprovider c = entityManager.find(MANOprovider.class, mpid);

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();/* w w w  . j av a  2  s  .  c o  m*/
    entityManager.remove(c);
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteVxFOnBoardedDescriptor(int mpid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();
    VxFOnBoardedDescriptor c = entityManager.find(VxFOnBoardedDescriptor.class, mpid);

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();//w w w.  j ava 2s  .c o  m
    entityManager.remove(c);
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteExperimentOnBoardDescriptor(int mpid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();
    ExperimentOnBoardDescriptor c = entityManager.find(ExperimentOnBoardDescriptor.class, mpid);

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();/*from  w w  w  .ja  v a 2  s  . c  o  m*/
    entityManager.remove(c);
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deletInfrastructure(int infraid) {

    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Infrastructure c = entityManager.find(Infrastructure.class, infraid);

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();/*w w w.j a  v a 2  s  .co m*/
    entityManager.remove(c);
    entityTransaction.commit();

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteUser(int userid) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    PortalUser u = entityManager.find(PortalUser.class, userid);

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();/*from  ww  w.  ja  va 2  s. c  o m*/

    entityManager.remove(u);

    entityTransaction.commit();
}

From source file:org.apache.juddi.api.impl.JUDDIApiImpl.java

/**
 * Delete's a client's subscription information. This is typically used for
 * server to server subscriptions/*from   w w  w  .ja  v a  2  s.com*/
 * Administrative privilege required.
 * @param body
 * @throws DispositionReportFaultMessage
 * @throws RemoteException 
 */
public void deleteClientSubscriptionInfo(DeleteClientSubscriptionInfo body)
        throws DispositionReportFaultMessage, RemoteException {

    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {
        tx.begin();

        UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());

        new ValidateClientSubscriptionInfo(publisher).validateDeleteClientSubscriptionInfo(em, body);

        List<String> entityKeyList = body.getSubscriptionKey();
        for (String entityKey : entityKeyList) {
            Object obj = em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, entityKey);
            em.remove(obj);
        }

        tx.commit();
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        em.close();
    }

}

From source file:portal.api.impl.PortalJpaController.java

public void deleteInstalledVxF(final InstalledVxF message) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();//from w w  w.  jav a2 s .  co  m

    entityManager.remove(message);

    entityTransaction.commit();
}