Example usage for org.springframework.orm.jpa EntityManagerFactoryUtils getTransactionalEntityManager

List of usage examples for org.springframework.orm.jpa EntityManagerFactoryUtils getTransactionalEntityManager

Introduction

In this page you can find the example usage for org.springframework.orm.jpa EntityManagerFactoryUtils getTransactionalEntityManager.

Prototype

@Nullable
public static EntityManager getTransactionalEntityManager(EntityManagerFactory emf)
        throws DataAccessResourceFailureException 

Source Link

Document

Obtain a JPA EntityManager from the given factory.

Usage

From source file:ispok.dao.CashgameSessionHibernateJpaDao.java

protected EntityManager getEntityManager() {
    return EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerfactory); //entity manager with @Transactional support
}

From source file:ispok.dao.BetsetHibernateJpaDao.java

private EntityManager getEntityManager() {
    return EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerfactory); //entity manager with @Transactional support
}

From source file:cz.cvut.wpa.prjmgr.DAO.HibernateDAO.java

/**
 * Get entity manager for the current transaction
 * @return/*from  w w  w  . j a v  a  2  s. com*/
 */
protected EntityManager getEntityManager() {
    return EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerfactory);
}

From source file:ispok.dao.TournamentHibernateJpaDao.java

private EntityManager getEntityManager() {
    return EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory); //entity manager with @Transactional support
}

From source file:org.grails.datastore.gorm.jpa.support.JpaPersistenceContextInterceptor.java

@Override
public void init() {
    entityManager = EntityManagerFactoryUtils
            .getTransactionalEntityManager(jpaDatastore.getEntityManagerFactory());
}

From source file:org.grails.datastore.gorm.jpa.support.JpaPersistenceContextInterceptor.java

@Override
public void reconnect() {
    entityManager = EntityManagerFactoryUtils
            .getTransactionalEntityManager(jpaDatastore.getEntityManagerFactory());
}

From source file:org.activiti.spring.SpringEntityManagerSessionFactory.java

public Session openSession() {
    EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
    if (entityManager == null) {
        return new EntityManagerSessionImpl(entityManagerFactory, handleTransactions, closeEntityManager);
    }/* w w w . j  a  v  a  2 s .  c  o m*/
    return new EntityManagerSessionImpl(entityManagerFactory, entityManager, false, false);
}

From source file:org.jasig.jpa.OpenEntityManagerAspect.java

/**
 * Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any.
 * @return the transactional EntityManager, or <code>null</code> if none
 * @throws IllegalStateException if this accessor is not configured with an EntityManagerFactory
 * @see EntityManagerFactoryUtils#getTransactionalEntityManager(javax.persistence.EntityManagerFactory)
 * @see EntityManagerFactoryUtils#getTransactionalEntityManager(javax.persistence.EntityManagerFactory, java.util.Map)
 *//* w w w.  j  a  v a2  s  . c  o  m*/
protected EntityManager getTransactionalEntityManager(EntityManagerFactory emf) throws IllegalStateException {
    Assert.state(emf != null, "No EntityManagerFactory specified");
    return EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
}

From source file:org.springframework.batch.item.database.JpaItemWriter.java

/**
 * Merge all provided items that aren't already in the persistence context
 * and then flush the entity manager.// w  w w.  j  a  v a2  s .  c  o  m
 *
 * @see org.springframework.batch.item.ItemWriter#write(java.util.List)
 */
@Override
public void write(List<? extends T> items) {
    EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
    if (entityManager == null) {
        throw new DataAccessResourceFailureException("Unable to obtain a transactional EntityManager");
    }
    doWrite(entityManager, items);
    entityManager.flush();
}

From source file:org.unitils.orm.jpa.JpaModule.java

protected EntityManager doGetPersistenceContext(Object testObject) {
    return EntityManagerFactoryUtils.getTransactionalEntityManager(getPersistenceUnit(testObject));
}