@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()
PersistencePersistenceTools bean.getTools in interface Persistencepublic DbTypeConverter getDbTypeConverter()
PersistencegetDbTypeConverter in interface Persistencepublic DbTypeConverter getDbTypeConverter(java.lang.String store)
PersistencegetDbTypeConverter in interface Persistencestore - data store namepublic void runInTransaction(Transaction.Runnable runnable)
PersistencerunInTransaction in interface PersistencePersistence.runInTransaction(String, Transaction.Runnable),
Persistence.callInTransaction(Transaction.Callable)public void runInTransaction(java.lang.String store,
Transaction.Runnable runnable)
PersistenceA RuntimeException thrown in the transactional code enforces a rollback.
runInTransaction in interface Persistencestore - data store namerunnable - transactional code in the form of Transaction.RunnablePersistence.callInTransaction(Transaction.Callable)public <T> T callInTransaction(Transaction.Callable<T> callable)
PersistencecallInTransaction in interface PersistencePersistence.callInTransaction(String, Transaction.Callable),
Persistence.runInTransaction(Transaction.Runnable)public <T> T callInTransaction(java.lang.String store,
Transaction.Callable<T> callable)
PersistenceReturns a result object created within the transaction.
A RuntimeException thrown in the transactional code enforces a rollback.
callInTransaction in interface PersistenceT - result typestore - data store namecallable - transactional code in the form of Transaction.CallablePersistence.runInTransaction(Transaction.Runnable)public Transaction createTransaction(TransactionParams params)
PersistencecreateTransaction in interface PersistencePersistence.createTransaction(TransactionParams)public Transaction createTransaction(java.lang.String store, TransactionParams params)
PersistencecreateTransaction in interface Persistencestore - data store nameparams - new transaction parameterspublic Transaction createTransaction()
PersistencecreateTransaction in interface PersistencePersistence.createTransaction(String)public Transaction createTransaction(java.lang.String store)
PersistencecreateTransaction in interface Persistencestore - data store namepublic Transaction getTransaction()
PersistencegetTransaction in interface PersistencePersistence.getTransaction(String)public Transaction getTransaction(java.lang.String store)
PersistenceIf 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 Persistencestore - data store namepublic boolean isInTransaction()
PersistenceisInTransaction in interface Persistencepublic EntityManager getEntityManager()
PersistencegetEntityManager in interface PersistencePersistence.getTransaction(String)public EntityManager getEntityManager(java.lang.String store)
PersistenceMust be invoked inside a transaction.
getEntityManager in interface Persistencepublic boolean isSoftDeletion()
PersistenceisSoftDeletion in interface Persistencepublic void setSoftDeletion(boolean value)
PersistenceEntityManagers created in
new transactions.setSoftDeletion in interface Persistencevalue - true if soft deletion is onpublic javax.sql.DataSource getDataSource()
getDataSource in interface Persistencepublic javax.sql.DataSource getDataSource(java.lang.String store)
getDataSource in interface Persistencepublic EntityManagerContext getEntityManagerContext()
PersistencegetEntityManagerContext in interface PersistencePersistence.getEntityManagerContext(String)public EntityManagerContext getEntityManagerContext(java.lang.String store)
PersistencegetEntityManagerContext in interface Persistencestore - data store namepublic void dispose()
public void registerSynchronizations(java.lang.String store)