public abstract class SharedEntityManagerCreator extends Object
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.
LocalEntityManagerFactoryBean
,
JpaTransactionManager
Constructor and Description |
---|
SharedEntityManagerCreator() |
Modifier and Type | Method and Description |
---|---|
static EntityManager |
createSharedEntityManager(EntityManagerFactory emf)
Create a transactional EntityManager proxy for the given EntityManagerFactory.
|
static EntityManager |
createSharedEntityManager(EntityManagerFactory emf,
Map properties)
Create a transactional EntityManager proxy for the given EntityManagerFactory.
|
static EntityManager |
createSharedEntityManager(EntityManagerFactory emf,
Map properties,
Class... entityManagerInterfaces)
Create a transactional EntityManager proxy for the given EntityManagerFactory.
|
public static EntityManager createSharedEntityManager(EntityManagerFactory emf)
emf
- the EntityManagerFactory to delegate to.
If this implements the EntityManagerFactoryInfo
interface,
appropriate handling of the native EntityManagerFactory and available
EntityManagerPlusOperations
will automatically apply.public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map properties)
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
)public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map properties, Class... entityManagerInterfaces)
emf
- EntityManagerFactory to obtain EntityManagers from as neededproperties
- 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.