@Component(value="cuba_Persistence") public class PersistenceImpl extends java.lang.Object implements Persistence
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
RUN_AFTER_COMPLETION_ATTR |
static java.lang.String |
RUN_BEFORE_COMMIT_ATTR |
NAME
Constructor and Description |
---|
PersistenceImpl() |
Modifier and Type | Method and Description |
---|---|
<T> T |
callInTransaction(java.lang.String store,
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 store)
Creates a new transaction.
If there is an active transaction, it will be suspended. |
Transaction |
createTransaction(java.lang.String store,
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.
|
void |
dispose()
INTERNAL.
|
javax.sql.DataSource |
getDataSource() |
javax.sql.DataSource |
getDataSource(java.lang.String store) |
DbTypeConverter |
getDbTypeConverter()
Returns DbTypeConverter for the current DBMS of the main data store.
|
DbTypeConverter |
getDbTypeConverter(java.lang.String store)
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 store)
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 store)
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 store)
Creates a new transaction if there is no one at the moment.
|
boolean |
isInTransaction()
Current transaction status.
|
boolean |
isSoftDeletion()
Global soft deletion attribute.
|
void |
registerSynchronizations(java.lang.String store)
INTERNAL.
|
void |
runInTransaction(java.lang.String store,
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 |
setFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean factoryBean) |
void |
setSoftDeletion(boolean value)
Set the global soft deletion attribute.
|
public static final java.lang.String RUN_BEFORE_COMMIT_ATTR
public static final java.lang.String RUN_AFTER_COMPLETION_ATTR
@Inject @Named(value="entityManagerFactory") public void setFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean factoryBean)
public PersistenceTools getTools()
Persistence
PersistenceTools
bean.getTools
in interface Persistence
public DbTypeConverter getDbTypeConverter()
Persistence
getDbTypeConverter
in interface Persistence
public DbTypeConverter getDbTypeConverter(java.lang.String store)
Persistence
getDbTypeConverter
in interface Persistence
store
- data store namepublic void runInTransaction(Transaction.Runnable runnable)
Persistence
runInTransaction
in interface Persistence
Persistence.runInTransaction(String, Transaction.Runnable)
,
Persistence.callInTransaction(Transaction.Callable)
public void runInTransaction(java.lang.String store, Transaction.Runnable runnable)
Persistence
A RuntimeException
thrown in the transactional code enforces a rollback.
runInTransaction
in interface Persistence
store
- data store namerunnable
- transactional code in the form of Transaction.Runnable
Persistence.callInTransaction(Transaction.Callable)
public <T> T callInTransaction(Transaction.Callable<T> callable)
Persistence
callInTransaction
in interface Persistence
Persistence.callInTransaction(String, Transaction.Callable)
,
Persistence.runInTransaction(Transaction.Runnable)
public <T> T callInTransaction(java.lang.String store, Transaction.Callable<T> callable)
Persistence
Returns a result object created within the transaction.
A RuntimeException
thrown in the transactional code enforces a rollback.
callInTransaction
in interface Persistence
T
- result typestore
- data store namecallable
- transactional code in the form of Transaction.Callable
Persistence.runInTransaction(Transaction.Runnable)
public Transaction createTransaction(TransactionParams params)
Persistence
createTransaction
in interface Persistence
Persistence.createTransaction(TransactionParams)
public Transaction createTransaction(java.lang.String store, TransactionParams params)
Persistence
createTransaction
in interface Persistence
store
- data store nameparams
- new transaction parameterspublic Transaction createTransaction()
Persistence
createTransaction
in interface Persistence
Persistence.createTransaction(String)
public Transaction createTransaction(java.lang.String store)
Persistence
createTransaction
in interface Persistence
store
- data store namepublic Transaction getTransaction()
Persistence
getTransaction
in interface Persistence
Persistence.getTransaction(String)
public Transaction getTransaction(java.lang.String store)
Persistence
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.getTransaction
in interface Persistence
store
- data store namepublic boolean isInTransaction()
Persistence
isInTransaction
in interface Persistence
public EntityManager getEntityManager()
Persistence
getEntityManager
in interface Persistence
Persistence.getTransaction(String)
public EntityManager getEntityManager(java.lang.String store)
Persistence
Must be invoked inside a transaction.
getEntityManager
in interface Persistence
public boolean isSoftDeletion()
Persistence
isSoftDeletion
in interface Persistence
public void setSoftDeletion(boolean value)
Persistence
EntityManager
s created in
new transactions.setSoftDeletion
in interface Persistence
value
- true if soft deletion is onpublic javax.sql.DataSource getDataSource()
getDataSource
in interface Persistence
public javax.sql.DataSource getDataSource(java.lang.String store)
getDataSource
in interface Persistence
public EntityManagerContext getEntityManagerContext()
Persistence
getEntityManagerContext
in interface Persistence
Persistence.getEntityManagerContext(String)
public EntityManagerContext getEntityManagerContext(java.lang.String store)
Persistence
getEntityManagerContext
in interface Persistence
store
- data store namepublic void dispose()
public void registerSynchronizations(java.lang.String store)