spring-framework / org.springframework.orm.jpa / SharedEntityManagerCreator

SharedEntityManagerCreator

abstract class SharedEntityManagerCreator

Delegate for creating a shareable JPA javax.persistence.EntityManager reference for a given javax.persistence.EntityManagerFactory.

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 javax.persistence.PersistenceContextType#TRANSACTION and its discussion in the JPA spec document. This is also the default being used for the annotation-based javax.persistence.PersistenceContext#type().

Author
Juergen Hoeller

Author
Rod Johnson

Author
Oliver Gierke

Since
2.0

See Also
javax.persistence.PersistenceContextjavax.persistence.PersistenceContextType#TRANSACTIONorg.springframework.orm.jpa.JpaTransactionManagerExtendedEntityManagerCreator

Constructors

<init>

SharedEntityManagerCreator()

Delegate for creating a shareable JPA javax.persistence.EntityManager reference for a given javax.persistence.EntityManagerFactory.

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 javax.persistence.PersistenceContextType#TRANSACTION and its discussion in the JPA spec document. This is also the default being used for the annotation-based javax.persistence.PersistenceContext#type().

Functions

createSharedEntityManager

open static fun createSharedEntityManager(emf: EntityManagerFactory): EntityManager
open static fun createSharedEntityManager(emf: EntityManagerFactory, properties: MutableMap<*, *>): EntityManager
open static fun createSharedEntityManager(emf: EntityManagerFactory, properties: MutableMap<*, *>, synchronizedWithTransaction: Boolean): EntityManager
open static fun createSharedEntityManager(emf: EntityManagerFactory, properties: MutableMap<*, *>, vararg entityManagerInterfaces: Class<*>): EntityManager
open static fun createSharedEntityManager(emf: EntityManagerFactory, properties: MutableMap<*, *>, synchronizedWithTransaction: Boolean, vararg entityManagerInterfaces: Class<*>): EntityManager

Create a transactional EntityManager proxy for the given EntityManagerFactory.