public abstract class ExtendedEntityManagerCreator
extends java.lang.Object
EntityManager
proxies that follow the JPA spec's semantics for "extended" EntityManagers.
Supports several different variants of "extended" EntityManagers:
in particular, an "application-managed extended EntityManager", as defined
by EntityManagerFactory.createEntityManager()
,
as well as a "container-managed extended EntityManager", as defined by
PersistenceContextType.EXTENDED
.
The original difference between "application-managed" and "container-managed"
was the need for explicit joining of an externally managed transaction through
the EntityManager.joinTransaction()
method in the "application" case
versus the automatic joining on each user-level EntityManager operation in the
"container" case. As of JPA 2.1, both join modes are available with both kinds of
EntityManagers, so the difference between "application-" and "container-managed"
is now primarily in the join mode default and in the restricted lifecycle of a
container-managed EntityManager (i.e. tied to the object that it is injected into).
EntityManagerFactory.createEntityManager()
,
PersistenceContextType.EXTENDED
,
EntityManager.joinTransaction()
,
SharedEntityManagerCreator
Constructor and Description |
---|
ExtendedEntityManagerCreator() |
Modifier and Type | Method and Description |
---|---|
static EntityManager |
createApplicationManagedEntityManager(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo)
Create an application-managed extended EntityManager proxy.
|
static EntityManager |
createApplicationManagedEntityManager(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo,
boolean synchronizedWithTransaction)
Create an application-managed extended EntityManager proxy.
|
static EntityManager |
createContainerManagedEntityManager(EntityManager rawEntityManager,
EntityManagerFactoryInfo emfInfo)
Create a container-managed extended EntityManager proxy.
|
static EntityManager |
createContainerManagedEntityManager(EntityManagerFactory emf)
Create a container-managed extended EntityManager proxy.
|
static EntityManager |
createContainerManagedEntityManager(EntityManagerFactory emf,
java.util.Map<?,?> properties)
Create a container-managed extended EntityManager proxy.
|
static EntityManager |
createContainerManagedEntityManager(EntityManagerFactory emf,
java.util.Map<?,?> properties,
boolean synchronizedWithTransaction)
Create a container-managed extended EntityManager proxy.
|
public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)
rawEntityManager
- the raw EntityManager to decorateemfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect
and PersistenceUnitInfo frompublic static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo, boolean synchronizedWithTransaction)
rawEntityManager
- the raw EntityManager to decorateemfInfo
- 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
- the raw EntityManager to decorateemfInfo
- 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.EntityManagerFactory.createEntityManager()
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, @Nullable 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
)EntityManagerFactory.createEntityManager(java.util.Map)
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, @Nullable 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)EntityManagerFactory.createEntityManager(java.util.Map)