public interface Persistence
RdbmsStore.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NAME |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
callInTransaction(java.lang.String storeName,
Transaction.Callable<T> callable)
Executes the action specified by the given single method object within a new transaction.
|
<T> T |
callInTransaction(Transaction.Callable<T> callable)
Executes the action specified by the given single method object within a new transaction in the main data store.
|
Transaction |
createTransaction()
Creates a new transaction in the main data store.
|
Transaction |
createTransaction(java.lang.String storeName)
Creates a new transaction.
If there is an active transaction, it will be suspended. |
Transaction |
createTransaction(java.lang.String storeName,
TransactionParams params)
Creates a new transaction.
If there is an active transaction, it will be suspended. |
Transaction |
createTransaction(TransactionParams params)
Creates a new transaction in the main data store.
|
javax.sql.DataSource |
getDataSource() |
javax.sql.DataSource |
getDataSource(java.lang.String storeName) |
DbTypeConverter |
getDbTypeConverter()
Returns DbTypeConverter for the current DBMS of the main data store.
|
DbTypeConverter |
getDbTypeConverter(java.lang.String storeName)
Returns DbTypeConverter for the current DBMS of the specified data store.
|
EntityManager |
getEntityManager()
Returns existing or creates a new transaction-bound EntityManager for the main data store,
which will be closed on transaction commit/rollback.
|
EntityManager |
getEntityManager(java.lang.String storeName)
Returns existing or creates a new transaction-bound EntityManager,
which will be closed on transaction commit/rollback.
|
EntityManagerContext |
getEntityManagerContext()
Returns context of the current EntityManager in the main data store.
|
EntityManagerContext |
getEntityManagerContext(java.lang.String storeName)
Returns context of the current EntityManager.
If not exists, a new instance of context created and returned. |
PersistenceTools |
getTools()
Convenient access to
PersistenceTools bean. |
Transaction |
getTransaction()
Creates a new transaction in the main data store if there is no one at the moment.
|
Transaction |
getTransaction(java.lang.String storeName)
Creates a new transaction if there is no one at the moment.
|
boolean |
isInTransaction()
Current transaction status.
|
boolean |
isSoftDeletion()
Global soft deletion attribute.
|
void |
runInTransaction(java.lang.String storeName,
Transaction.Runnable runnable)
Executes the action specified by the given single method object within a new transaction.
|
void |
runInTransaction(Transaction.Runnable runnable)
Executes the action specified by the given single method object within a new transaction in the main data store.
|
void |
setSoftDeletion(boolean value)
Set the global soft deletion attribute.
|
static final java.lang.String NAME
PersistenceTools getTools()
PersistenceTools bean.DbTypeConverter getDbTypeConverter()
DbTypeConverter getDbTypeConverter(java.lang.String storeName)
storeName - data store name<T> T callInTransaction(Transaction.Callable<T> callable)
<T> T callInTransaction(java.lang.String storeName,
Transaction.Callable<T> callable)
Returns a result object created within the transaction.
A RuntimeException thrown in the transactional code enforces a rollback.
T - result typestoreName - data store namecallable - transactional code in the form of Transaction.CallablerunInTransaction(Transaction.Runnable)void runInTransaction(Transaction.Runnable runnable)
void runInTransaction(java.lang.String storeName,
Transaction.Runnable runnable)
A RuntimeException thrown in the transactional code enforces a rollback.
storeName - data store namerunnable - transactional code in the form of Transaction.RunnablecallInTransaction(Transaction.Callable)@CheckReturnValue Transaction createTransaction(TransactionParams params)
createTransaction(TransactionParams)@CheckReturnValue Transaction createTransaction(java.lang.String storeName, TransactionParams params)
storeName - data store nameparams - new transaction parameters@CheckReturnValue Transaction createTransaction()
createTransaction(String)@CheckReturnValue Transaction createTransaction(java.lang.String storeName)
storeName - data store name@CheckReturnValue Transaction getTransaction()
getTransaction(String)@CheckReturnValue Transaction getTransaction(java.lang.String storeName)
If a transaction exists, joins the current transaction. In this case:
Transaction.commit() does not affect current transaction.Transaction.end() is called without previous Transaction.commit(), current
transaction is marked as rollback-only, so any attempt to commit the surrounding Transaction will
throw an exception.storeName - data store nameboolean isInTransaction()
@CheckReturnValue EntityManager getEntityManager()
getTransaction(String)@CheckReturnValue EntityManager getEntityManager(java.lang.String storeName)
Must be invoked inside a transaction.
boolean isSoftDeletion()
void setSoftDeletion(boolean value)
EntityManagers created in
new transactions.value - true if soft deletion is onjavax.sql.DataSource getDataSource()
javax.sql.DataSource getDataSource(java.lang.String storeName)
EntityManagerContext getEntityManagerContext()
getEntityManagerContext(String)EntityManagerContext getEntityManagerContext(java.lang.String storeName)
storeName - data store name