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 javax.persistence.EntityManagerFactory | get() Returns EntityManagerFactory . |
static javax.persistence.EntityManagerFactory | get(java.lang.String configName) Returns EntityManagerFactory . |
static javax.persistence.EntityManager | getEntityManager() Returns EntityManager for persistence operations. |
static javax.persistence.EntityManager | getEntityManager(java.lang.String configName) Returns EntityManager for persistence operations. |
static java.lang.Object | getTransaction(javax.persistence.EntityManager em) Returns started transaction. |
static java.lang.Object | getTransaction(java.lang.String configName, javax.persistence.EntityManager em) Returns started transaction. |
static void | returnEntityManager(javax.persistence.EntityManager em) Closes EntityManager . |
static void | returnEntityManager(java.lang.String configName, javax.persistence.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 javax.persistence.EntityManagerFactory get()
EntityManagerFactory
. Using default configuration.EntityManagerFactory
or null.public static javax.persistence.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 javax.persistence.EntityManager getEntityManager() throws javax.persistence.PersistenceException
EntityManager
for persistence operations. Using default configuration.EntityManager
for persistence operations.javax.persistence.PersistenceException
- if unable to acquire EntityManager
.public static javax.persistence.EntityManager getEntityManager(java.lang.String configName) throws javax.persistence.PersistenceException
EntityManager
for persistence operations.configName
- String
configuration name. Default provider is used if null
or empty string is passed.EntityManager
for persistence operations.javax.persistence.PersistenceException
- if unable to acquire EntityManager
.public static void returnEntityManager(javax.persistence.EntityManager em)
EntityManager
. Using default configuration.em
- EntityManager
which should be closed.public static void returnEntityManager(java.lang.String configName, javax.persistence.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(javax.persistence.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, javax.persistence.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.