类 SharedEntityManagerCreator
- java.lang.Object
- org.springframework.orm.jpa.SharedEntityManagerCreator
public abstract class SharedEntityManagerCreator extends Object
Delegate for creating a shareable JPAEntityManager
reference for a givenEntityManagerFactory
.A shared 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.
For a behavioral definition of such a shared transactional EntityManager, see
PersistenceContextType.TRANSACTION
and its discussion in the JPA spec document. This is also the default being used for the annotation-basedPersistenceContext.type()
.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, Rod Johnson, Oliver Gierke
- 另请参阅:
PersistenceContext
,PersistenceContextType.TRANSACTION
,JpaTransactionManager
,ExtendedEntityManagerCreator
构造器概要
构造器 构造器 说明 SharedEntityManagerCreator()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 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, boolean synchronizedWithTransaction)
Create a transactional EntityManager proxy for the given EntityManagerFactory.static EntityManager
createSharedEntityManager(EntityManagerFactory emf, Map<?,?> properties, boolean synchronizedWithTransaction, Class<?>... entityManagerInterfaces)
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.
构造器详细资料
SharedEntityManagerCreator
public SharedEntityManagerCreator()
方法详细资料
createSharedEntityManager
public static EntityManager createSharedEntityManager(EntityManagerFactory emf)
Create a transactional EntityManager proxy for the given EntityManagerFactory.- 参数:
emf
- the EntityManagerFactory to delegate to.- 返回:
- a shareable transaction EntityManager proxy
createSharedEntityManager
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?,?> properties)
Create a transactional EntityManager proxy for the given EntityManagerFactory.- 参数:
emf
- the EntityManagerFactory to delegate to.properties
- the properties to be passed into thecreateEntityManager
call (may benull
)- 返回:
- a shareable transaction EntityManager proxy
createSharedEntityManager
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?,?> properties, boolean synchronizedWithTransaction)
Create a transactional EntityManager proxy for the given EntityManagerFactory.- 参数:
emf
- the EntityManagerFactory to delegate to.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 shareable transaction EntityManager proxy
- 从以下版本开始:
- 4.0
createSharedEntityManager
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?,?> properties, Class<?>... entityManagerInterfaces)
Create a transactional EntityManager proxy for the given EntityManagerFactory.- 参数:
emf
- the EntityManagerFactory to obtain EntityManagers from as neededproperties
- the properties to be passed into thecreateEntityManager
call (may benull
)entityManagerInterfaces
- the interfaces to be implemented by the EntityManager. Allows the addition or specification of proprietary interfaces.- 返回:
- a shareable transactional EntityManager proxy
createSharedEntityManager
public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?,?> properties, boolean synchronizedWithTransaction, Class<?>... entityManagerInterfaces)
Create a transactional EntityManager proxy for the given EntityManagerFactory.- 参数:
emf
- the EntityManagerFactory to obtain EntityManagers from as neededproperties
- 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)entityManagerInterfaces
- the interfaces to be implemented by the EntityManager. Allows the addition or specification of proprietary interfaces.- 返回:
- a shareable transactional EntityManager proxy
- 从以下版本开始:
- 4.0