org.springframework.orm.jpa
Class SharedEntityManagerCreator

java.lang.Object
  extended by org.springframework.orm.jpa.SharedEntityManagerCreator

public abstract class SharedEntityManagerCreator
extends Object

Factory for a shareable JPA EntityManager for a given EntityManagerFactory.

The shareable EntityManager will behave just like an EntityManager fetched from an application server's JNDI environment, as defined by the JPA specification. It will delegate all calls to the current transactional EntityManager, if any; otherwise it will fall back to a newly created EntityManager per operation.

Since:
2.0
Author:
Juergen Hoeller, Rod Johnson
See Also:
LocalEntityManagerFactoryBean, JpaTransactionManager

Constructor Summary
SharedEntityManagerCreator()
           
 
Method Summary
static javax.persistence.EntityManager createSharedEntityManager(javax.persistence.EntityManagerFactory emf)
          Create a transactional EntityManager proxy for the given EntityManagerFactory.
static javax.persistence.EntityManager createSharedEntityManager(javax.persistence.EntityManagerFactory emf, Map properties)
          Create a transactional EntityManager proxy for the given EntityManagerFactory.
static javax.persistence.EntityManager createSharedEntityManager(javax.persistence.EntityManagerFactory emf, Map properties, Class... entityManagerInterfaces)
          Create a transactional EntityManager proxy for the given EntityManagerFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedEntityManagerCreator

public SharedEntityManagerCreator()
Method Detail

createSharedEntityManager

public static javax.persistence.EntityManager createSharedEntityManager(javax.persistence.EntityManagerFactory emf)
Create a transactional EntityManager proxy for the given EntityManagerFactory.

Parameters:
emf - the EntityManagerFactory to delegate to. If this implements the EntityManagerFactoryInfo interface, appropriate handling of the native EntityManagerFactory and available EntityManagerPlusOperations will automatically apply.
Returns:
a shareable transaction EntityManager proxy

createSharedEntityManager

public static javax.persistence.EntityManager createSharedEntityManager(javax.persistence.EntityManagerFactory emf,
                                                                        Map properties)
Create a transactional EntityManager proxy for the given EntityManagerFactory.

Parameters:
emf - the EntityManagerFactory to delegate to. If this implements the EntityManagerFactoryInfo interface, appropriate handling of the native EntityManagerFactory and available EntityManagerPlusOperations will automatically apply.
properties - the properties to be passed into the createEntityManager call (may be null)
Returns:
a shareable transaction EntityManager proxy

createSharedEntityManager

public static javax.persistence.EntityManager createSharedEntityManager(javax.persistence.EntityManagerFactory emf,
                                                                        Map properties,
                                                                        Class... entityManagerInterfaces)
Create a transactional EntityManager proxy for the given EntityManagerFactory.

Parameters:
emf - EntityManagerFactory to obtain EntityManagers from as needed
properties - the properties to be passed into the createEntityManager call (may be null)
entityManagerInterfaces - the interfaces to be implemented by the EntityManager. Allows the addition or specification of proprietary interfaces.
Returns:
a shareable transactional EntityManager proxy