public class JtaEntityManagerRegistry extends 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(String deploymentId,
Object primaryKey,
Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> entityManagers)
Adds the entity managers for the specified component to the registry.
|
javax.persistence.EntityManager |
getEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory,
Map properties,
boolean extended,
String unitName)
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(javax.persistence.EntityManagerFactory entityManagerFactory)
Gets an exiting extended entity manager created by a component down the call stack.
|
boolean |
isTransactionActive()
Is a transaction active?
|
Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> |
removeEntityManagers(String deploymentId,
Object primaryKey)
Removed the registered entity managers for the specified component.
|
void |
transactionStarted(String deploymentId,
Object primaryKey)
Notifies the registry that a user transaction has been started or the specified component.
|
public JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry)
public javax.persistence.EntityManager getEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory,
Map properties,
boolean extended,
String unitName)
throws 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 - IllegalStateException - if the entity manger is extended and there is not an existing entity manager
instance already registeredpublic void addEntityManagers(String deploymentId, Object primaryKey, Map<javax.persistence.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 Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> removeEntityManagers(String deploymentId, Object primaryKey)
deploymentId - the id of the componentpublic JtaEntityManagerRegistry.EntityManagerTracker getInheritedEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory)
entityManagerFactory - the entity manager factory from which an entity manager is neededpublic void transactionStarted(String deploymentId, Object primaryKey)
deploymentId - the id of the componentpublic boolean isTransactionActive()
Copyright © 1999–2014 The Apache Software Foundation. All rights reserved.