public class EMFProviderLMT extends java.lang.Object implements EMFProviderInterface
EntityManagerFactory
is created in static initialization block and used to create EntityManager
objects.Modifier and Type | Field and Description |
---|---|
protected EntityManagerFactory | emf Holds EntityManagerFactory . |
ENTITY_MANAGER, ENTITY_MANAGER_FACTORY, JPA_ENTITY_MANAGER, JPA_ENTITY_MANAGER_FACTORY, JPA_PERSISTENCE_UNIT_NAME, JPA_TRANSACTION, PERSISTENCE_UNIT_NAME, TRANSACTION
Constructor and Description |
---|
EMFProviderLMT() Creates new EMF provider. |
EMFProviderLMT(java.util.Properties config) Creates new EMF provider. |
EMFProviderLMT(java.lang.String persistenceUnitName) Creates new EMF provider with specified persistence unit name. |
Modifier and Type | Method and Description |
---|---|
void | commitTransaction(java.lang.Object tx) Commits specified transaction. |
EntityManagerFactory | get() Returns EntityManagerFactory . |
EntityManager | getEntityManager() Returns EntityManager created using factory. |
java.lang.Object | getTransaction(EntityManager em) Returns started transaction. Creates transaction with em.getTransaction () and starts it. |
void | returnEntityManager(EntityManager em) Closes EntityManager . |
void | rollbackTransaction(java.lang.Object tx) Rolls back specified transaction. |
public EMFProviderLMT()
public EMFProviderLMT(java.util.Properties config)
config
- Properties
for provider configuration.public EMFProviderLMT(java.lang.String persistenceUnitName)
persistenceUnitName
- String
name of persistence unit.public EntityManagerFactory get()
EntityManagerFactory
.get
in interface EMFProviderInterface
EntityManagerFactory
for locally managed transactions.public EntityManager getEntityManager() throws PersistenceException
EntityManager
created using factory.getEntityManager
in interface EMFProviderInterface
EntityManager
for persistence operations.PersistenceException
- if unable to acquire EntityManager
.public void returnEntityManager(EntityManager em)
EntityManager
.returnEntityManager
in interface EMFProviderInterface
em
- EntityManager
which should be closed.public java.lang.Object getTransaction(EntityManager em) throws java.lang.Exception
em.getTransaction ()
and starts it.getTransaction
in interface EMFProviderInterface
em
- EntityManager
needed if joining to existing transaction or starting transaction locally.Object
Already started transaction for persistence operations.PersistenceException
- if unable to acquire or open transaction.java.lang.Exception
- if unable to acquire or open transaction.public void commitTransaction(java.lang.Object tx) throws java.lang.Exception
tx.commit ()
.commitTransaction
in interface EMFProviderInterface
tx
- Object
transaction to be commited.java.lang.Exception
- occured while committing transaction.public void rollbackTransaction(java.lang.Object tx)
tx.rollback ()
.rollbackTransaction
in interface EMFProviderInterface
tx
- Object
transaction to be rolled back.