jakarta.persistence.EntityManager
reference for a given jakarta.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 jakarta. and its
discussion in the JPA spec document. This is also the default being used
for the annotation-based jakarta..
jakarta.persistence.PersistenceContext , jakarta.persistence.PersistenceContextType#TRANSACTION , org.springframework.orm.jpa.JpaTransactionManager , ExtendedEntityManagerCreator
| Modifier and Type | Class and Description |
|---|---|
| private static class | SharedEntityManagerCreator.DeferredQueryInvocationHandler
Invocation handler that handles deferred Query objects created by non-transactional createQuery invocations on a shared EntityManager. |
| private static class | SharedEntityManagerCreator.SharedEntityManagerInvocationHandler
Invocation handler that delegates all calls to the current transactional EntityManager, if any; else, it will fall back to a newly created EntityManager per operation. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | |
| private static final Class | |
| private static final Set | |
| private static final Set |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static EntityManager | Returns: a shareable transaction EntityManager proxythe EntityManagerFactory to delegate to. emf)Create a transactional EntityManager proxy for the given EntityManagerFactory. |
| public static EntityManager | Returns: a shareable transaction EntityManager proxythe EntityManagerFactory to delegate to. emf, Map<?, ?> the properties to be passed into the
properties)createEntityManager call (may be null)Create a transactional EntityManager proxy for the given EntityManagerFactory. |
| public static EntityManager | Returns: a shareable transaction EntityManager proxythe EntityManagerFactory to delegate to. emf, Map<?, ?> the properties to be passed into the
properties, boolean createEntityManager call (may be null)whether to automatically join ongoing
transactions (according to the JPA 2.1 SynchronizationType rules) synchronizedWithTransaction)Create a transactional EntityManager proxy for the given EntityManagerFactory. |
| public static EntityManager | Returns: a shareable transactional EntityManager proxythe EntityManagerFactory to obtain EntityManagers from as needed emf, Map<?, ?> the properties to be passed into the
properties, Class<?>... createEntityManager call (may be null)the interfaces to be implemented by the
EntityManager. Allows the addition or specification of proprietary interfaces. entityManagerInterfaces)Create a transactional EntityManager proxy for the given EntityManagerFactory. |
| public static EntityManager | Returns: a shareable transactional EntityManager proxythe EntityManagerFactory to obtain EntityManagers from as needed emf, Map<?, ?> the properties to be passed into the
properties, boolean createEntityManager call (may be null)whether to automatically join ongoing
transactions (according to the JPA 2.1 SynchronizationType rules) synchronizedWithTransaction, Class<?>... the interfaces to be implemented by the
EntityManager. Allows the addition or specification of proprietary interfaces. entityManagerInterfaces)Create a transactional EntityManager proxy for the given EntityManagerFactory. |
| cachedQueryInterfaces | back to summary |
|---|---|
| private static final Map<Class<?>, Class<?>[]> cachedQueryInterfaces | |
| NO_ENTITY_MANAGER_INTERFACES | back to summary |
|---|---|
| private static final Class<?>[] NO_ENTITY_MANAGER_INTERFACES | |
| queryTerminatingMethods | back to summary |
|---|---|
| private static final Set<String> queryTerminatingMethods | |
| transactionRequiringMethods | back to summary |
|---|---|
| private static final Set<String> transactionRequiringMethods | |
| SharedEntityManagerCreator | back to summary |
|---|---|
| public SharedEntityManagerCreator() | |
| createSharedEntityManager | back to summary |
|---|---|
| public static EntityManager createSharedEntityManager(EntityManagerFactory emf) Create a transactional EntityManager proxy for the given EntityManagerFactory.
| |
| createSharedEntityManager | back to summary |
|---|---|
| public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?, ?> properties) Create a transactional EntityManager proxy for the given EntityManagerFactory.
| |
| createSharedEntityManager | back to summary |
|---|---|
| public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction) Create a transactional EntityManager proxy for the given EntityManagerFactory.
| |
| createSharedEntityManager | back to summary |
|---|---|
| public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?, ?> properties, Class<?>... entityManagerInterfaces) Create a transactional EntityManager proxy for the given EntityManagerFactory.
| |
| createSharedEntityManager | back to summary |
|---|---|
| public static EntityManager createSharedEntityManager(EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction, Class<?>... entityManagerInterfaces) Create a transactional EntityManager proxy for the given EntityManagerFactory.
| |
Includes deferred output parameter access for JPA 2.1 StoredProcedureQuery, retrieving the corresponding values for all registered parameters on query termination and returning the locally cached values for subsequent access.