public class EMF
extends java.lang.Object
EntityManager
and transaction with helper methods. Configuration is read from server.properties file. Value of property jpa.emfProvider specifies actual implementation. Methods hiding EntityManager
and transaction object initialization are used by JPADataSource
: getEntityManager
returnEntityManager
getTransaction
commitTransaction
rollbackTransaction
Modifier and Type | Field and Description |
---|---|
static java.lang.String | EMF_PROVIDER Name of sub property for JPA EMF provider implementation. |
static java.lang.String | JPA_EMF_PROVIDER Name of property for JPA EMF provider implementation. |
static java.lang.String | JPA_PREFIX Name of prefix for JPA EMF provider block. |
static java.lang.String | TRANSACTION_ATTR Attribute name for RPCManager. |
Modifier and Type | Method and Description |
---|---|
static void | commitTransaction(java.lang.Object tx) Commits specified transaction. |
static void | commitTransaction(java.lang.String configName, java.lang.Object tx) Commits specified transaction. |
static EntityManagerFactory | get() Returns EntityManagerFactory . |
static EntityManagerFactory | get(java.lang.String configName) Returns EntityManagerFactory . |
static EntityManager | getEntityManager() Returns EntityManager for persistence operations. |
static EntityManager | getEntityManager(java.lang.String configName) Returns EntityManager for persistence operations. |
static java.lang.Object | getTransaction(EntityManager em) Returns started transaction. |
static java.lang.Object | getTransaction(java.lang.String configName, EntityManager em) Returns started transaction. |
static void | returnEntityManager(EntityManager em) Closes EntityManager . |
static void | returnEntityManager(java.lang.String configName, EntityManager em) Closes EntityManager . |
static void | rollbackTransaction(java.lang.Object tx) Rolls back specified transaction. |
static void | rollbackTransaction(java.lang.String configName, java.lang.Object tx) Rolls back specified transaction. |
public static final java.lang.String JPA_PREFIX
public static final java.lang.String EMF_PROVIDER
public static final java.lang.String JPA_EMF_PROVIDER
public static final java.lang.String TRANSACTION_ATTR
public static EntityManagerFactory get()
EntityManagerFactory
. Using default configuration.EntityManagerFactory
or null.public static EntityManagerFactory get(java.lang.String configName)
EntityManagerFactory
.configName
- String
configuration name. Default provider is used if null
or empty string is passed.EntityManagerFactory
or null.public static EntityManager getEntityManager() throws PersistenceException
EntityManager
for persistence operations. Using default configuration.EntityManager
for persistence operations.PersistenceException
- if unable to acquire EntityManager
.public static EntityManager getEntityManager(java.lang.String configName) throws PersistenceException
EntityManager
for persistence operations.configName
- String
configuration name. Default provider is used if null
or empty string is passed.EntityManager
for persistence operations.PersistenceException
- if unable to acquire EntityManager
.public static void returnEntityManager(EntityManager em)
EntityManager
. Using default configuration.em
- EntityManager
which should be closed.public static void returnEntityManager(java.lang.String configName, EntityManager em)
EntityManager
.configName
- String
configuration name. Default provider is used if null
or empty string is passed.em
- EntityManager
which should be closed.public static java.lang.Object getTransaction(EntityManager em) throws java.lang.Exception
em
- EntityManager
needed if joining to existing transaction or starting transaction locally.Object
Already started transaction for persistence operations.java.lang.Exception
- if unable to acquire or open transaction.public static java.lang.Object getTransaction(java.lang.String configName, EntityManager em) throws java.lang.Exception
configName
- String
configuration name. Default provider is used if null
or empty string is passed.em
- EntityManager
needed if joining to existing transaction or starting transaction locally.Object
Already started transaction for persistence operations.java.lang.Exception
- if unable to acquire or open transaction.public static void commitTransaction(java.lang.Object tx) throws java.lang.Exception
tx
- Object
transaction to be commited.java.lang.Exception
- occured while committing transaction.public static void commitTransaction(java.lang.String configName, java.lang.Object tx) throws java.lang.Exception
configName
- String
configuration name. Default provider is used if null
or empty string is passed.tx
- Object
transaction to be commited.java.lang.Exception
- occured while committing transaction.public static void rollbackTransaction(java.lang.Object tx)
tx
- Object
transaction to be rolled back.public static void rollbackTransaction(java.lang.String configName, java.lang.Object tx)
configName
- String
configuration name. Default provider is used if null
or empty string is passed.tx
- Object
transaction to be rolled back.