类 ExtendedEntityManagerCreator
- java.lang.Object
- org.springframework.orm.jpa.ExtendedEntityManagerCreator
public abstract class ExtendedEntityManagerCreator extends Object
Delegate for creating a variety ofEntityManager
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 byPersistenceContextType.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).- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, Rod Johnson
- 另请参阅:
EntityManagerFactory.createEntityManager()
,PersistenceContextType.EXTENDED
,EntityManager.joinTransaction()
,SharedEntityManagerCreator
构造器概要
构造器 构造器 说明 ExtendedEntityManagerCreator()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 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(EntityManagerFactory emf)
Create a container-managed extended EntityManager proxy.static EntityManager
createContainerManagedEntityManager(EntityManagerFactory emf, Map<?,?> properties)
Create a container-managed extended EntityManager proxy.static EntityManager
createContainerManagedEntityManager(EntityManagerFactory emf, Map<?,?> properties, boolean synchronizedWithTransaction)
Create a container-managed extended EntityManager proxy.static EntityManager
createContainerManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)
Create a container-managed extended EntityManager proxy.
构造器详细资料
ExtendedEntityManagerCreator
public ExtendedEntityManagerCreator()
方法详细资料
createApplicationManagedEntityManager
public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)
Create an application-managed extended EntityManager proxy.- 参数:
rawEntityManager
- the raw EntityManager to decorateemfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect and PersistenceUnitInfo from- 返回:
- an application-managed EntityManager that can join transactions but does not participate in them automatically
createApplicationManagedEntityManager
public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo, boolean synchronizedWithTransaction)
Create an application-managed extended EntityManager proxy.- 参数:
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)- 返回:
- an application-managed EntityManager that can join transactions but does not participate in them automatically
- 从以下版本开始:
- 4.0
createContainerManagedEntityManager
public static EntityManager createContainerManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)
Create a container-managed extended EntityManager proxy.- 参数:
rawEntityManager
- the raw EntityManager to decorateemfInfo
- the EntityManagerFactoryInfo to obtain the JpaDialect and PersistenceUnitInfo from- 返回:
- a container-managed EntityManager that will automatically participate in any managed transaction
createContainerManagedEntityManager
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf)
Create a container-managed extended EntityManager proxy.- 参数:
emf
- the EntityManagerFactory to create the EntityManager with. If this implements the EntityManagerFactoryInfo interface, the corresponding JpaDialect and PersistenceUnitInfo will be detected accordingly.- 返回:
- a container-managed EntityManager that will automatically participate in any managed transaction
- 另请参阅:
EntityManagerFactory.createEntityManager()
createContainerManagedEntityManager
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, Map<?,?> properties)
Create a container-managed extended EntityManager proxy.- 参数:
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 thecreateEntityManager
call (may benull
)- 返回:
- a container-managed EntityManager that will automatically participate in any managed transaction
- 另请参阅:
EntityManagerFactory.createEntityManager(java.util.Map)
createContainerManagedEntityManager
public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf, Map<?,?> properties, boolean synchronizedWithTransaction)
Create a container-managed extended EntityManager proxy.- 参数:
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 thecreateEntityManager
call (may benull
)synchronizedWithTransaction
- whether to automatically join ongoing transactions (according to the JPA 2.1 SynchronizationType rules)- 返回:
- a container-managed EntityManager that expects container-driven lifecycle management but may opt out of automatic transaction synchronization
- 从以下版本开始:
- 4.0
- 另请参阅:
EntityManagerFactory.createEntityManager(java.util.Map)