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,
        @Nullable Map<?, ?> properties) throws DataAccessResourceFailureException 

Source Link

Document

Obtain a JPA EntityManager from the given factory.

Usage

From source file:org.codehaus.grepo.query.jpa.repository.DefaultJpaRepository.java

/**
 * @return Returns the transaction manager.
 * @throws IllegalStateException in case factory is null
 *///  w  w w  .  j  av  a2  s .  c  o m
protected EntityManager getTransactionalEntityManager() throws IllegalStateException {
    Assert.state(getEntityManagerFactory() != null, "No EntityManagerFactory specified");
    return EntityManagerFactoryUtils.getTransactionalEntityManager(getEntityManagerFactory(),
            getJpaPropertyMap());
}

From source file:org.springframework.orm.jpa.EntityManagerFactoryAccessor.java

/**
 * Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any.
 * @return the transactional EntityManager, or {@code null} 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  ww.j a va2 s.c  o m*/
@Nullable
protected EntityManager getTransactionalEntityManager() throws IllegalStateException {
    EntityManagerFactory emf = obtainEntityManagerFactory();
    return EntityManagerFactoryUtils.getTransactionalEntityManager(emf, getJpaPropertyMap());
}