public class JtaEntityManagerRegistry
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JtaEntityManagerRegistry.EntityManagerTracker
This object is used track all EntityManagers inherited in order
to effectively close it when the latest Extended persistence context
is no more accessed.
|
| Constructor and Description |
|---|
JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry)
Creates a JtaEntityManagerRegistry using the specified transactionSynchronizationRegistry for the registry
if transaction associated entity managers.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEntityManagers(java.lang.String deploymentId,
java.lang.Object primaryKey,
java.util.Map<EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> entityManagers)
Adds the entity managers for the specified component to the registry.
|
EntityManager |
getEntityManager(EntityManagerFactory entityManagerFactory,
java.util.Map properties,
boolean extended,
java.lang.String unitName,
SynchronizationType synchronizationType)
Gets an entity manager instance from the transaction registry, extended registry or for a transaction scoped
entity manager, creates a new one when an existing instance is not found.
|
JtaEntityManagerRegistry.EntityManagerTracker |
getInheritedEntityManager(EntityManagerFactory entityManagerFactory)
Gets an exiting extended entity manager created by a component down the call stack.
|
boolean |
isTransactionActive()
Is a transaction active?
|
java.util.Map<EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> |
removeEntityManagers(java.lang.String deploymentId,
java.lang.Object primaryKey)
Removed the registered entity managers for the specified component.
|
void |
transactionStarted(java.lang.String deploymentId,
java.lang.Object primaryKey)
Notifies the registry that a user transaction has been started or the specified component.
|
public JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry)
public EntityManager getEntityManager(EntityManagerFactory entityManagerFactory,
java.util.Map properties,
boolean extended,
java.lang.String unitName,
SynchronizationType synchronizationType)
throws java.lang.IllegalStateException
entityManagerFactory - the entity manager factory from which an entity manager is requiredproperties - the properties passed to the entity manager factory when an entity manager is createdextended - is the entity manager an extended contextunitName - java.lang.IllegalStateException - if the entity manger is extended and there is not an existing entity manager
instance already registeredpublic void addEntityManagers(java.lang.String deploymentId,
java.lang.Object primaryKey,
java.util.Map<EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> entityManagers)
throws EntityManagerAlreadyRegisteredException
deploymentId - the id of the componententityManagers - the entity managers to registerEntityManagerAlreadyRegisteredException - if an entity manager is already registered with the transaction
for one of the supplied entity manager factories; for EJBs this should be caught and rethown as an EJBExceptionpublic java.util.Map<EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> removeEntityManagers(java.lang.String deploymentId, java.lang.Object primaryKey)
deploymentId - the id of the componentpublic JtaEntityManagerRegistry.EntityManagerTracker getInheritedEntityManager(EntityManagerFactory entityManagerFactory)
entityManagerFactory - the entity manager factory from which an entity manager is neededpublic void transactionStarted(java.lang.String deploymentId,
java.lang.Object primaryKey)
deploymentId - the id of the componentpublic boolean isTransactionActive()