To acquire EntityManager
:
<persistence-context-ref> <persistence-context-ref-name>REFERENCE_TO_ENTITY_MANAGER</persistence-context-ref-name> <persistence-unit-name>PERSISTENCE_UNIT_NAME</persistence-unit-name> </persistence-context-ref>To acquire
EntityManagerFactory
: <persistence-unit-ref> <persistence-unit-ref-name>REFERENCE_TO_ENTITY_MANAGER_FACTORY</persistence-unit-ref-name> <persistence-unit-name>PERSISTENCE_UNIT_NAME</persistence-unit-name> </persistence-unit-ref>
getTransaction()
will return instance of UserTransaction
located in "java:comp/UserTransaction" in JNDI. ENTITY_MANAGER, ENTITY_MANAGER_FACTORY, JPA_ENTITY_MANAGER, JPA_ENTITY_MANAGER_FACTORY, JPA_PERSISTENCE_UNIT_NAME, JPA_TRANSACTION, PERSISTENCE_UNIT_NAME, TRANSACTION
EMFProviderBMT(String entityManagerRef, String entityManagerFactoryRef)
EMFProviderBMT(Properties config)
void
jakarta.persistence.EntityManagerFactory
get()
EntityManagerFactory
found in container's environment context.jakarta.persistence.EntityManager
EntityManager
found in container's environment context.getTransaction(jakarta.persistence.EntityManager em)
UserTransaction
found in container's environment context.void
returnEntityManager(jakarta.persistence.EntityManager em)
EntityManager
.void
EntityManager
and EntityManagerFactory
in container's environment context.EntityManager
and EntityManagerFactory
in container's environment context.config
- Properties
for provider configuration.entityManagerRef
- String
name of context reference to entity manager.entityManagerFactoryRef
- String
name of context reference to entity manager factory.EntityManagerFactory
found in container's environment context.get
in interface EMFProviderInterface
EntityManagerFactory
can be used to acquire meta-data (for JPA 2.0) or implement "application managed entity manager" pattern.EntityManager
found in container's environment context.getEntityManager
in interface EMFProviderInterface
EntityManager
for persistence operations.jakarta.persistence.PersistenceException
- if unable to acquire EntityManager
.EntityManager
.returnEntityManager
in interface EMFProviderInterface
em
- EntityManager
which should be closed.UserTransaction
found in container's environment context.getTransaction
in interface EMFProviderInterface
em
- EntityManager
needed if joining to existing transaction or null.Object
Transaction for persistence operations.jakarta.persistence.PersistenceException
- if unable to acquire or open transaction.Exception
- if unable to acquire or open transaction.tx.commit()
. Throws PersistenceException
if transaction already rolled back.commitTransaction
in interface EMFProviderInterface
tx
- Object
transaction to be committed.Exception
- occurred while committing transaction.tx.rollback()
.rollbackTransaction
in interface EMFProviderInterface
tx
- Object
transaction to be rolled back.