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:portal.api.impl.PortalJpaController.java

public PortalUser updatePortalUser(PortalUser bu) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();//  ww w  .  j a v a2s .c om
    PortalUser resis = entityManager.merge(bu);
    entityTransaction.commit();

    return resis;
}

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

public PortalProperty updateProperty(PortalProperty p) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();//from  www  .  j  av  a  2s. c  om
    PortalProperty bp = entityManager.merge(p);
    entityTransaction.commit();

    return bp;
}

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

public MANOplatform updateMANOplatform(MANOplatform c) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();// w ww .j a va  2s .  c o  m
    MANOplatform resis = entityManager.merge(c);
    entityTransaction.commit();

    return resis;
}

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

public MANOprovider updateMANOprovider(MANOprovider c) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();/*from  w  ww  . j  a  v a2  s.c o  m*/
    MANOprovider resis = entityManager.merge(c);
    entityTransaction.commit();

    return resis;
}

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

public InstalledVxF updateInstalledVxF(InstalledVxF is) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();//  w ww . j a  va 2s.c o  m
    InstalledVxF resis = entityManager.merge(is);
    entityTransaction.commit();

    return resis;
}

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

public Infrastructure updateInfrastructure(Infrastructure c) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();/* ww  w .j a va 2  s.  c o  m*/
    Infrastructure resis = entityManager.merge(c);
    entityTransaction.commit();

    return resis;
}

From source file:org.apache.juddi.v3.auth.jboss.JBossAuthenticator.java

/**
  */* w ww.  java  2  s  . c  om*/
  */
public String authenticate(final String userID, final String credential) throws AuthenticationException {
    if (userID == null) {
        throw new UnknownUserException(new ErrorMessage("errors.auth.InvalidUserId", userID));
    }

    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {
        // Create a principal for the userID
        Principal principal = new Principal() {
            public String getName() {
                return userID;
            }
        };

        if (!authManager.isValid(principal, credential)) {
            throw new UnknownUserException(new ErrorMessage("errors.auth.InvalidCredentials"));
        } else {
            tx.begin();
            Publisher publisher = em.find(Publisher.class, userID);
            if (publisher == null) {
                publisher = new Publisher();
                publisher.setAuthorizedName(userID);
                publisher.setIsAdmin("false");
                publisher.setIsEnabled("true");
                publisher.setMaxBindingsPerService(199);
                publisher.setMaxBusinesses(100);
                publisher.setMaxServicesPerBusiness(100);
                publisher.setMaxTmodels(100);
                publisher.setPublisherName("Unknown");
                em.persist(publisher);
                tx.commit();
            }
        }
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        em.close();
    }
    return userID;
}

From source file:org.eclipse.smila.connectivity.deltaindexing.jpa.impl.DeltaIndexingManagerImpl.java

/**
 * {@inheritDoc}//from  www. j  a  va  2 s  . c  om
 * 
 * @see org.eclipse.smila.connectivity.deltaindexing.DeltaIndexingManager#unlockDatasource(String)
 */
@Override
public void unlockDatasource(final String dataSourceID) throws DeltaIndexingException {
    _lock.readLock().lock();
    try {
        final EntityManager em = createEntityManager();
        final EntityTransaction transaction = em.getTransaction();
        try {
            transaction.begin();
            final Query query = em.createNamedQuery(DataSourceDao.NAMED_QUERY_KILL_SESSION);
            query.setParameter(DeltaIndexingDao.NAMED_QUERY_PARAM_SOURCE, dataSourceID);
            query.executeUpdate();
            transaction.commit();
            if (_log.isInfoEnabled()) {
                _log.info("removed delta indexing sessions and unlocked data source " + dataSourceID);
            }
        } catch (final Exception e) {
            if (transaction.isActive()) {
                transaction.rollback();
            }
            throw new DeltaIndexingException("error unlocking delta indexing data source " + dataSourceID, e);
        } finally {
            closeEntityManager(em);
        }
    } finally {
        _lock.readLock().unlock();
    }
}

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

public VxFOnBoardedDescriptor updateVxFOnBoardedDescriptor(VxFOnBoardedDescriptor c) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();

    entityTransaction.begin();//  ww w  . j  a  va 2s .c  o m
    VxFOnBoardedDescriptor resis = entityManager.merge(c);
    entityTransaction.commit();

    return resis;
}

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

public void saveInfrastructure(Infrastructure c) {
    logger.info("Will save ExperimentOnBoardDescriptors = " + c.getName());

    EntityManager entityManager = entityManagerFactory.createEntityManager();

    EntityTransaction entityTransaction = entityManager.getTransaction();
    entityTransaction.begin();//from  www  . ja v  a2s .c  o m
    entityManager.persist(c);
    entityManager.flush();
    entityTransaction.commit();

}