public abstract class ExtendedEntityManagerCreator
extends java.lang.Object
Supports explicit joining of a transaction through the
joinTransaction()
method ("application-managed extended
EntityManager") as well as automatic joining on each operation
("container-managed extended EntityManager").
Modifier and Type | Class and Description |
---|---|
private static class |
ExtendedEntityManagerCreator.ExtendedEntityManagerInvocationHandler
InvocationHandler for extended EntityManagers as defined in the JPA spec.
|
private static class |
ExtendedEntityManagerCreator.ExtendedEntityManagerSynchronization
TransactionSynchronization enlisting an extended EntityManager
with a current Spring transaction.
|
Constructor and Description |
---|
ExtendedEntityManagerCreator() |
Modifier and Type | Method and Description |
---|---|
static EntityManager |
createApplicationManagedEntityManager(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo)
Create an EntityManager that can join transactions with the
joinTransaction()
method, but is not automatically managed by the container. |
static EntityManager |
createApplicationManagedEntityManager(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo,
boolean synchronizedWithTransaction)
Create an EntityManager that can join transactions with the
joinTransaction()
method, but is not automatically managed by the container. |
static EntityManager |
createContainerManagedEntityManager(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo)
Create an EntityManager whose lifecycle is managed by the container and which
automatically joins a transaction when being invoked within its scope.
|
static EntityManager |
createContainerManagedEntityManager(EntityManagerFactory emf)
Create an EntityManager whose lifecycle is managed by the container and which
automatically joins a transaction when being invoked within its scope.
|
static EntityManager |
createContainerManagedEntityManager(EntityManagerFactory emf,
java.util.Map properties)
Create an EntityManager whose lifecycle is managed by the container and which
automatically joins a transaction when being invoked within its scope.
|
static EntityManager |
createContainerManagedEntityManager(EntityManagerFactory emf,
java.util.Map properties,
boolean synchronizedWithTransaction)
Create an EntityManager whose lifecycle is managed by the container and which
may automatically join a transaction when being invoked within its scope.
|
private static EntityManager |
createProxy(EntityManager rawEm,
java.lang.Class<? extends EntityManager> emIfc,
java.lang.ClassLoader cl,
PersistenceExceptionTranslator exceptionTranslator,
java.lang.Boolean jta,
boolean containerManaged,
boolean synchronizedWithTransaction)
Actually create the EntityManager proxy.
|
private static EntityManager |
createProxy(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo,
boolean containerManaged,
boolean synchronizedWithTransaction)
Actually create the EntityManager proxy.
|
public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)
joinTransaction()
method, but is not automatically managed by the container.rawEntityManager
- raw EntityManageremfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect
and PersistenceUnitInfo frompublic static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo, boolean synchronizedWithTransaction)
joinTransaction()
method, but is not automatically managed by the container.rawEntityManager
- raw EntityManageremfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect
and PersistenceUnitInfo fromsynchronizedWithTransaction
- whether to automatically join ongoing
transactions (according to the JPA 2.1 SynchronizationType rules)public static EntityManager createContainerManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)
rawEntityManager
- raw EntityManageremfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect
and PersistenceUnitInfo frompublic static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf)
emf
- the EntityManagerFactory to create the EntityManager with.
If this implements the EntityManagerFactoryInfo interface, the corresponding
JpaDialect and PersistenceUnitInfo will be detected accordingly.javax.persistence.EntityManagerFactory#createEntityManager()
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, java.util.Map properties)
emf
- the EntityManagerFactory to create the EntityManager with.
If this implements the EntityManagerFactoryInfo interface, the corresponding
JpaDialect and PersistenceUnitInfo will be detected accordingly.properties
- the properties to be passed into the createEntityManager
call (may be null
)javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, java.util.Map properties, boolean synchronizedWithTransaction)
emf
- the EntityManagerFactory to create the EntityManager with.
If this implements the EntityManagerFactoryInfo interface, the corresponding
JpaDialect and PersistenceUnitInfo will be detected accordingly.properties
- the properties to be passed into the createEntityManager
call (may be null
)synchronizedWithTransaction
- whether to automatically join ongoing
transactions (according to the JPA 2.1 SynchronizationType rules)javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)
private static EntityManager createProxy(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo, boolean containerManaged, boolean synchronizedWithTransaction)
rawEntityManager
- raw EntityManageremfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect
and PersistenceUnitInfo fromcontainerManaged
- whether to follow container-managed EntityManager
or application-managed EntityManager semanticssynchronizedWithTransaction
- whether to automatically join ongoing
transactions (according to the JPA 2.1 SynchronizationType rules)private static EntityManager createProxy(EntityManager rawEm, java.lang.Class<? extends EntityManager> emIfc, java.lang.ClassLoader cl, PersistenceExceptionTranslator exceptionTranslator, java.lang.Boolean jta, boolean containerManaged, boolean synchronizedWithTransaction)
rawEm
- raw EntityManageremIfc
- the (potentially vendor-specific) EntityManager
interface to proxy, or null
for default detection of all interfacescl
- the ClassLoader to use for proxy creation (maybe null
)exceptionTranslator
- the PersistenceException translator to usejta
- whether to create a JTA-aware EntityManager
(or null
if not known in advance)containerManaged
- whether to follow container-managed EntityManager
or application-managed EntityManager semanticssynchronizedWithTransaction
- whether to automatically join ongoing
transactions (according to the JPA 2.1 SynchronizationType rules)