Class Transaction
- java.lang.Object
-
- de.hybris.platform.tx.Transaction
-
- Direct Known Subclasses:
DefaultTransaction
public abstract class Transaction extends java.lang.Object
The base class of all supported transaction types
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Transaction.TransactionAwareExecution
protected static interface
Transaction.TransactionFactory
protected class
Transaction.TxInvalidationSet
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<java.lang.Object>
attachedObjects
static boolean
captureInvalidationStackTraces
static java.lang.String
CFG_ENABLE_TX_CACHE
static java.lang.String
CFG_ROLLBACK_ON_COMMIT_ERROR
static java.lang.ThreadLocal<java.lang.Long>
lastStartTL
-
Constructor Summary
Constructors Constructor Description Transaction()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activateAsCurrentTransaction()
Makes this transaction the new current transaction.void
activateCache(boolean activate)
activated the cache for the current transaction (thread).void
addDelayedConstraint(Item item, Item.ItemConstraint constr)
void
addToDelayedRemoval(EntityInstance entity)
void
addToDelayedRollbackLocalInvalidations(java.lang.Object[] key, int type, int topicdepth)
protected void
assertNoCurrentTransactionRunning()
void
attach(java.lang.Object objectToAttach)
void
begin()
protected void
beginOuter()
protected ConnectionImpl
bindConnection(Tenant tenant, boolean userTAEnabled)
protected boolean
calculatedUserTAEnabled(Tenant t)
protected void
checkBeforeCommit()
protected void
checkBeforeRollback()
protected void
checkDelayedConstrains()
protected void
checkForOtherCurrentTxRunning()
void
clearDelayedConstrains(PK itemPK)
protected void
clearRollbackOnly()
protected void
clearTxBoundConnectionAndNotify(boolean isCommit)
protected void
clearTxBoundConnectionAndNotifyCommit()
protected void
clearTxBoundConnectionAndNotifyRollback()
void
commit()
protected void
commitConnectionAndClearAndUnsetAsCurrent()
protected static Transaction
createNew()
static Transaction
current()
Returns the current transaction instance.protected void
decreaseOpenTransactionCount()
boolean
dettach(java.lang.Object objectToAttach)
void
enableDelayedStore(boolean delay)
the "delayed store" feature enables you to delay all item modifications until the end of the transaction.void
enableTxCache(boolean enable)
For a running transaction this method allow to define whether or not a local cache should be used.static void
enableUserTransactionForThread(boolean enable)
Enable or disable the user of UserTransactions for the current thread.java.lang.Object
execute(TransactionBody transactionBody)
Executes given code inside the current transaction.java.lang.Object
execute(TransactionBody transactionBody, java.lang.Class<? extends java.lang.Exception>... permittedExceptions)
Executes given code inside the current transaction.boolean
executeOnCommit(Transaction.TransactionAwareExecution ex)
void
executeOnRollback(Transaction.TransactionAwareExecution ex)
void
executeOrDelayStore(EntityInstance entity)
protected void
finishExecute(java.lang.Throwable thrown, TransactionBody body, java.lang.Class<? extends java.lang.Exception>... permittedExceptions)
void
flushDelayedStore()
All entity modification delayed within the current transaction will be made persistent right now.protected void
flushDelayedStore(EntityInstance entity)
protected AfterSaveListenerRegistry
getAfterSaveEventListenerRegistry()
<T> T
getAttached(java.lang.Class<T> classOfAttachedObject)
EntityInstance
getAttachedEntityInstance(PK pk)
java.util.Queue<java.lang.Throwable>
getBeginTransactionStack()
Returns a stack frame for currents transactionbegin()
.protected ConnectionImpl
getConnectionToBind(HybrisDataSource dataSource)
java.lang.Object
getContextEntry(java.lang.Object key)
protected static Transaction
getCurrentIfExists()
protected AfterSaveEventChangesCollector
getEntityChangesCollector()
long
getObjectID()
returns a unique id for this Transaction object.int
getOpenTransactionCount()
Returns the number of transactions that are open for this thread, which is of course 0 if no transaction is running, 1 if a transaction is running, 2 if we have a nested transaction and so on.protected TransactionAwareCache
getOrCreateGlobalCacheAdapter(Cache globalCache)
protected TransactionAwareCache
getOrCreateLegacyCacheAdapter(Cache globalCache)
protected TransactionAwareCache
getOrCreateTxLocalCacheAdapter(Cache globalCache)
EntityInstance
getOrLoadTxBoundEntityInstance(PersistencePool pool, java.lang.String jndi, PK pk)
TransactionAwareCache
getTransactionAwareCache(Cache globalCache)
protected static Transaction.TransactionFactory
getTransactionsFactory()
ConnectionImpl
getTXBoundConnection()
Inside a transaction this method returns the transaction bound database connection.protected void
increaseOpenTransactionCount()
void
invalidate(AbstractCacheUnit unit, int invalidationType)
void
invalidate(AbstractCacheUnit unit, int invalidationType, boolean sendImmediately)
void
invalidate(java.lang.Object[] key, int invalidationTopicDepth, int invalidationType)
void
invalidate(java.lang.Object[] key, int invalidationTopicDepth, int invalidationType, boolean sendImmediately)
void
invalidateAndNotifyCommit(java.lang.Object[] key, int invalidationDepth, int invalidationType)
void
invalidateAndNotifyRollback(java.lang.Object[] key, int invalidationDepth, int invalidationType)
void
invalidateFromDirectPersistence(java.lang.Object[] key, PK pk, int invalidationType)
boolean
isCurrent()
boolean
isDelayedStoreEnabled()
returns true if all entity modifications should be delayed until the end of the TX.protected boolean
isExceptionIsPermitted(java.lang.Throwable thrown, java.lang.Class<? extends java.lang.Exception>... permittedExceptions)
static boolean
isInCommitOrRollback()
Checks whether there is a transaction running in the current thread and this transaction is in commit or rollback phase (including invalidation phase).boolean
isInvalidated(java.lang.Object[] key)
boolean
isNested()
boolean
isRollbackOnCommitError()
boolean
isRollbackOnly()
Tells if this transaction has been marked as rollback-only.boolean
isRunning()
Tells if there is currently a active transaction.boolean
isTxCacheEnabled()
Tells whether this (running) transaction is using a local cache for all lookups which cannot be backed by the global 2n level cache due to this transaction having invalidation recorded affecting the lookup.static boolean
isUserTransactionEnabled()
check the value set using the enableUserTransactionForThread(Boolean) method.protected void
loadAfterSaveListenerRegistry()
void
lock(Item item)
Lock's an entity for update, performing a row-level lock on the database.protected void
logBeforeBegin()
protected void
logBeforeCommit()
protected void
logBeforeRollback()
void
notifyCommit()
void
notifyRollback()
protected void
onNestedBeginError(java.lang.Exception e)
protected void
onOuterBeginError(java.lang.Exception e)
static Transaction
performCommitBeginEvery(Transaction existingTransaction, int ms)
Helper method to commit a transaction after it's running over given amount of time.void
printContextInfo()
void
registerEntityInstance(EntityInstance instance)
void
reloadEntityInstance(PK pk)
protected void
removeFromEntityMap(PK pk)
void
rollback()
protected void
rollbackConnection()
protected void
rollbackConnection(ConnectionImpl con)
protected void
rollbackOuter()
protected void
setAsCurrent()
void
setContextEntry(java.lang.Object key, java.lang.Object value)
void
setRollbackOnCommitError(boolean rollback)
If set totrue
any error happening during database commit will cause also a rollback on database level.void
setRollbackOnly()
Marks this transaction as rollback only.protected static void
setTransactionFactory(Transaction.TransactionFactory transactionFactory)
void
setTransactionIsolationLevel(int level)
Allows to choose the transaction isolation level to be used for starting a new transaction.static <ET extends java.lang.Exception>
ETtoException(java.lang.Throwable e, java.lang.Class<ET> businessExceptionClass)
Utility method to help handling business exceptions coming fromexecute(TransactionBody)
method.protected static void
unsetTransactionFactory()
protected void
unsetTxBoundConnection()
boolean
useCache(AbstractCacheUnit cache)
protected abstract boolean
useCacheInternal(AbstractCacheUnit cacheUnit)
by implementing this method subclasses can influence the result ofuseCache(AbstractCacheUnit)
-
-
-
Field Detail
-
CFG_ROLLBACK_ON_COMMIT_ERROR
public static java.lang.String CFG_ROLLBACK_ON_COMMIT_ERROR
-
CFG_ENABLE_TX_CACHE
public static final java.lang.String CFG_ENABLE_TX_CACHE
- See Also:
- Constant Field Values
-
captureInvalidationStackTraces
public static boolean captureInvalidationStackTraces
-
lastStartTL
public static final java.lang.ThreadLocal<java.lang.Long> lastStartTL
-
attachedObjects
protected final java.util.ArrayList<java.lang.Object> attachedObjects
-
-
Method Detail
-
setTransactionFactory
protected static void setTransactionFactory(Transaction.TransactionFactory transactionFactory)
-
unsetTransactionFactory
protected static void unsetTransactionFactory()
-
getTransactionsFactory
protected static Transaction.TransactionFactory getTransactionsFactory()
-
getEntityChangesCollector
protected AfterSaveEventChangesCollector getEntityChangesCollector()
-
printContextInfo
public void printContextInfo()
-
getBeginTransactionStack
public java.util.Queue<java.lang.Throwable> getBeginTransactionStack()
Returns a stack frame for currents transactionbegin()
. For diagnostic purposes only.
-
current
public static Transaction current()
Returns the current transaction instance. Please note that creating nested transactions by callingbegin()
does not create new transaction instances. After finishing the (outermost) transaction viacommit()
orrollback()
the instance is discarded. The next call tocurrent()
creates a new instance.
-
getCurrentIfExists
protected static Transaction getCurrentIfExists()
-
isCurrent
public boolean isCurrent()
-
createNew
protected static Transaction createNew()
-
getObjectID
public long getObjectID()
returns a unique id for this Transaction object. Note that this ID stays the same if you call begin(), commit() more than once on the same object- Returns:
- the unique object ID
-
isRunning
public final boolean isRunning()
Tells if there is currently a active transaction. Oncebegin()
has been called the transaction is considered to be active. After callingcommit()
orrollback()
the transaction is no longer active. If nested transactions are started it returnstrue
untilcommit()
orrollback()
has been called on the outermost transaction even if inner transactions have been ended via commit or rollback.
-
isNested
public boolean isNested()
-
setRollbackOnly
public final void setRollbackOnly()
Marks this transaction as rollback only. If this transaction is nested all enclosing transactions are marked rollback-only too. Callingcommit()
afterwards will in fact roll back the transaction and throw aTransactionException
to indicate that commit has not been successful (only outermost transaction - nested transactions do not throw a exception). Example:Transaction.current().begin(); { Transaction.current().begin(); { Transaction.current().setRollbackOnly(); } Transaction.current().commit(); // no exception here; no commit or rollback either } Transaction.current().commit(); // throws exception + does rollback
-
isRollbackOnly
public boolean isRollbackOnly()
Tells if this transaction has been marked as rollback-only. This happens by callingsetRollbackOnly()
orrollback()
upon a nested transaction. SeesetRollbackOnly()
for more details.
-
clearRollbackOnly
protected void clearRollbackOnly()
-
isInCommitOrRollback
public static boolean isInCommitOrRollback()
Checks whether there is a transaction running in the current thread and this transaction is in commit or rollback phase (including invalidation phase). This phase includes the commit/rollback call to the database and the followed notification/invalidation. Note: Do not use this method in your business code. This is a hybris internal method.- Returns:
- true in case transaction is in commit or rollback phase
- Since:
- 3.1-u4
-
getOpenTransactionCount
public int getOpenTransactionCount()
Returns the number of transactions that are open for this thread, which is of course 0 if no transaction is running, 1 if a transaction is running, 2 if we have a nested transaction and so on.- Returns:
- the number of open transactions for this thread
-
increaseOpenTransactionCount
protected void increaseOpenTransactionCount()
-
decreaseOpenTransactionCount
protected void decreaseOpenTransactionCount()
-
calculatedUserTAEnabled
protected boolean calculatedUserTAEnabled(Tenant t)
-
begin
public void begin() throws TransactionException
- Throws:
TransactionException
-
onNestedBeginError
protected void onNestedBeginError(java.lang.Exception e)
-
onOuterBeginError
protected void onOuterBeginError(java.lang.Exception e)
-
checkForOtherCurrentTxRunning
protected void checkForOtherCurrentTxRunning()
-
beginOuter
protected void beginOuter()
-
loadAfterSaveListenerRegistry
protected void loadAfterSaveListenerRegistry()
-
getAfterSaveEventListenerRegistry
protected AfterSaveListenerRegistry getAfterSaveEventListenerRegistry()
-
bindConnection
protected ConnectionImpl bindConnection(Tenant tenant, boolean userTAEnabled)
-
logBeforeBegin
protected void logBeforeBegin()
-
getConnectionToBind
protected ConnectionImpl getConnectionToBind(HybrisDataSource dataSource) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
commit
public void commit() throws TransactionException
- Throws:
TransactionException
-
commitConnectionAndClearAndUnsetAsCurrent
protected void commitConnectionAndClearAndUnsetAsCurrent()
-
checkBeforeCommit
protected void checkBeforeCommit()
-
logBeforeCommit
protected void logBeforeCommit()
-
toException
public static <ET extends java.lang.Exception> ET toException(java.lang.Throwable e, java.lang.Class<ET> businessExceptionClass)
Utility method to help handling business exceptions coming fromexecute(TransactionBody)
method.
-
clearTxBoundConnectionAndNotifyCommit
protected void clearTxBoundConnectionAndNotifyCommit()
-
clearTxBoundConnectionAndNotifyRollback
protected void clearTxBoundConnectionAndNotifyRollback()
-
clearTxBoundConnectionAndNotify
protected void clearTxBoundConnectionAndNotify(boolean isCommit)
-
unsetTxBoundConnection
protected void unsetTxBoundConnection()
-
checkDelayedConstrains
protected void checkDelayedConstrains() throws ConsistencyCheckException
- Throws:
ConsistencyCheckException
-
invalidateAndNotifyCommit
public void invalidateAndNotifyCommit(java.lang.Object[] key, int invalidationDepth, int invalidationType)
-
notifyCommit
public void notifyCommit()
-
rollback
public void rollback() throws TransactionException
- Throws:
TransactionException
-
checkBeforeRollback
protected void checkBeforeRollback()
-
logBeforeRollback
protected void logBeforeRollback()
-
rollbackOuter
protected void rollbackOuter()
-
rollbackConnection
protected void rollbackConnection() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
rollbackConnection
protected void rollbackConnection(ConnectionImpl con) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
invalidateAndNotifyRollback
public void invalidateAndNotifyRollback(java.lang.Object[] key, int invalidationDepth, int invalidationType)
-
notifyRollback
public void notifyRollback()
-
execute
public java.lang.Object execute(TransactionBody transactionBody) throws java.lang.Exception
Executes given code inside the current transaction. If this transaction is not currently running it will be started and committed at the end of execution. Otherwise whetherbegin
norcommit
is called since the enclosing transaction will do that.In case an exception is raised and this method started the transaction itself it will rollback any changes. If no own transaction was started the exception is simply thrown to the calling code.
- Parameters:
transactionBody
- the code to execute within this transaction- Returns:
- the object returned by the executed code
- Throws:
java.lang.Exception
- in case the executed code raised an exception
-
execute
public java.lang.Object execute(TransactionBody transactionBody, java.lang.Class<? extends java.lang.Exception>... permittedExceptions) throws java.lang.Exception
Executes given code inside the current transaction. If this transaction is not currently running it will be started and committed at the end of execution. Otherwise whetherbegin
norcommit
is called since the enclosing transaction will do that.In case an exception is raised and this method started the transaction itself it will rollback any changes. If no own transaction was started the exception is simply thrown to the calling code.
- Parameters:
transactionBody
- the code to execute within this transactionpermittedExceptions
- a list of exception classes which are actually allowed to be thrown without the transaction being rolled back; may be null if no exceptions are allowed to do so- Returns:
- the object returned by the executed code
- Throws:
java.lang.Exception
- in case the executed code raised an exception
-
finishExecute
protected void finishExecute(java.lang.Throwable thrown, TransactionBody body, java.lang.Class<? extends java.lang.Exception>... permittedExceptions) throws java.lang.Exception
- Throws:
java.lang.Exception
-
isExceptionIsPermitted
protected boolean isExceptionIsPermitted(java.lang.Throwable thrown, java.lang.Class<? extends java.lang.Exception>... permittedExceptions)
-
getContextEntry
public java.lang.Object getContextEntry(java.lang.Object key)
-
setContextEntry
public void setContextEntry(java.lang.Object key, java.lang.Object value)
-
invalidate
public void invalidate(AbstractCacheUnit unit, int invalidationType)
-
invalidate
public void invalidate(AbstractCacheUnit unit, int invalidationType, boolean sendImmediately)
-
invalidate
public void invalidate(java.lang.Object[] key, int invalidationTopicDepth, int invalidationType)
-
invalidateFromDirectPersistence
public void invalidateFromDirectPersistence(java.lang.Object[] key, PK pk, int invalidationType)
-
removeFromEntityMap
protected void removeFromEntityMap(PK pk)
-
invalidate
public void invalidate(java.lang.Object[] key, int invalidationTopicDepth, int invalidationType, boolean sendImmediately)
-
addToDelayedRollbackLocalInvalidations
public void addToDelayedRollbackLocalInvalidations(java.lang.Object[] key, int type, int topicdepth)
-
useCache
public final boolean useCache(AbstractCacheUnit cache)
-
activateCache
public void activateCache(boolean activate)
activated the cache for the current transaction (thread). WARNING: if deactivating the cache be sure you reactivate it inside a finally{} clause to avoid slowdown of the system.- Parameters:
activate
- true to activate, false to deactivate- Since:
- 2.0
-
useCacheInternal
protected abstract boolean useCacheInternal(AbstractCacheUnit cacheUnit)
by implementing this method subclasses can influence the result ofuseCache(AbstractCacheUnit)
-
isInvalidated
public boolean isInvalidated(java.lang.Object[] key)
- Returns:
- true if the given key will be invalidated by executeInvalidations()
-
enableDelayedStore
public void enableDelayedStore(boolean delay)
the "delayed store" feature enables you to delay all item modifications until the end of the transaction. note that if you set this parameter it will be resetted after each commit/rollback to the global parameter "transaction.delayedstore" in your project|local.properties.
-
setRollbackOnCommitError
public void setRollbackOnCommitError(boolean rollback)
If set totrue
any error happening during database commit will cause also a rollback on database level. Normally this is not necessary but should be considered in case database transactions are still open after commit.Also see configuration parameter 'transaction.rollbackOnCommitError' which allows to enable this globally.
-
isRollbackOnCommitError
public boolean isRollbackOnCommitError()
-
isDelayedStoreEnabled
public boolean isDelayedStoreEnabled()
returns true if all entity modifications should be delayed until the end of the TX. If not used the enableDelayedStore() method, the result will be the preset given in the parameter "transaction.delayedstore" (or true if this has not been specified)
-
flushDelayedStore
public void flushDelayedStore()
All entity modification delayed within the current transaction will be made persistent right now. Please note that no changes will be written to database in case this transaction is already marked asrollback-only
!
-
flushDelayedStore
protected void flushDelayedStore(EntityInstance entity)
-
executeOrDelayStore
public void executeOrDelayStore(EntityInstance entity)
-
addToDelayedRemoval
public void addToDelayedRemoval(EntityInstance entity)
-
executeOnRollback
public void executeOnRollback(Transaction.TransactionAwareExecution ex)
-
executeOnCommit
public boolean executeOnCommit(Transaction.TransactionAwareExecution ex)
-
enableUserTransactionForThread
public static void enableUserTransactionForThread(boolean enable)
Enable or disable the user of UserTransactions for the current thread. If you globally want to enable/disable this feature, use the config parameter transaction.enable=true|false (can be found in the project.properties).- Parameters:
enable
- true to enable, false to disable UserTransactions for the current thread- Since:
- 1.3.1
-
isUserTransactionEnabled
public static boolean isUserTransactionEnabled()
check the value set using the enableUserTransactionForThread(Boolean) method. Note that there may be more parameters that are checked internally if a UserTransaction should be started, eg. this method may return true, but the global configuration parameter "transaction.enable" is set to false. in this case no transaction is started.- Returns:
- false, if the user transactions are disabled using the 'enableUserTransactionForThread(..)' method, true otherwise.
- Since:
- 1.3.1
-
activateAsCurrentTransaction
public void activateAsCurrentTransaction()
Makes this transaction the new current transaction.- Throws:
java.lang.IllegalStateException
- if there is still a current transaction set which is running.- Since:
- 2.10
-
assertNoCurrentTransactionRunning
protected void assertNoCurrentTransactionRunning()
-
setAsCurrent
protected void setAsCurrent()
-
registerEntityInstance
public void registerEntityInstance(EntityInstance instance)
-
getOrLoadTxBoundEntityInstance
public EntityInstance getOrLoadTxBoundEntityInstance(PersistencePool pool, java.lang.String jndi, PK pk)
- Parameters:
pool
-jndi
-pk
-- Throws:
YNoSuchEntityException
- is there is no item for the given pk
-
getAttachedEntityInstance
public EntityInstance getAttachedEntityInstance(PK pk)
-
reloadEntityInstance
public void reloadEntityInstance(PK pk)
-
getTXBoundConnection
public ConnectionImpl getTXBoundConnection()
Inside a transaction this method returns the transaction bound database connection.- Throws:
java.lang.IllegalStateException
- if called outside a transaction
-
setTransactionIsolationLevel
public void setTransactionIsolationLevel(int level)
Allows to choose the transaction isolation level to be used for starting a new transaction. Please set before starting. Otherwise behavior is not defined (seeConnection.setTransactionIsolation(int)
for details)!Use as follows:
Transaction tx = Transaction.current(); tx.setTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED); tx.begin(); // ... business code tx.commit();
Also note that after commit or rolling back the isolation level setting is cleared - it has to be set for each transaction anew!
- Parameters:
level
- the level - seeConnection
for details
-
performCommitBeginEvery
public static Transaction performCommitBeginEvery(Transaction existingTransaction, int ms)
Helper method to commit a transaction after it's running over given amount of time.This method performs a commit on existing transaction and starts new one when elapsed transaction time exceeds given threshold. When new transaction is started, it is returned so that the caller can use it to do further transaction processing (e.g. commit()).
- Parameters:
existingTransaction
- existing transactionms
- transaction time threshold- Returns:
- New transaction object if the elapsed transaction time is greater than the threshold. Existing transaction otherwise.
-
clearDelayedConstrains
public void clearDelayedConstrains(PK itemPK)
-
addDelayedConstraint
public void addDelayedConstraint(Item item, Item.ItemConstraint constr)
-
lock
public void lock(Item item) throws java.lang.IllegalStateException
Lock's an entity for update, performing a row-level lock on the database.Calls to
lock
can only be made between calls tobegin()
andcommit()
orrollback()
. All locks that are acquired during a transaction are automatically released on calls tocommit()
orrollback()
. If a lock is held by another transaction, this method will block until the lock can be acquired.Depending on a the DBMS, a lock on a single row may result in locking an entire page. Locks should not be acquired on long-running transactions unless absolutely necessary. Note, that on some DBMS's, such as HSQLDB, row-level locking is not supported and any attempt to perform a lock will throw an UnsupportedOperationException.
Also note that it's crucial to use the correct
isolation level
for getting the correct result after locking a item. For instance if you expect that a attribute ma have been changed while waiting for that lock it may be a good idea to useConnection.TRANSACTION_READ_COMMITTED
to allow reading these changed values!- Parameters:
item
- The entity to lock- Throws:
java.lang.NullPointerException
- If an null value is passed into thelock
method or if no primary key has been assigned to the entity.java.lang.IllegalStateException
- If an attempt is made to lock an entity outside the bounds of the transaction, or an attempt is made to lock an entity that does not exist in the database.java.lang.UnsupportedOperationException
- If the database does not support SELECT FOR UPDATE
-
getTransactionAwareCache
public TransactionAwareCache getTransactionAwareCache(Cache globalCache)
-
getOrCreateGlobalCacheAdapter
protected TransactionAwareCache getOrCreateGlobalCacheAdapter(Cache globalCache)
-
getOrCreateTxLocalCacheAdapter
protected TransactionAwareCache getOrCreateTxLocalCacheAdapter(Cache globalCache)
-
getOrCreateLegacyCacheAdapter
protected TransactionAwareCache getOrCreateLegacyCacheAdapter(Cache globalCache)
-
isTxCacheEnabled
public boolean isTxCacheEnabled()
Tells whether this (running) transaction is using a local cache for all lookups which cannot be backed by the global 2n level cache due to this transaction having invalidation recorded affecting the lookup.The default mode is
true
and has the config settingCFG_ENABLE_TX_CACHE
.- See Also:
enableTxCache(boolean)
-
enableTxCache
public void enableTxCache(boolean enable)
For a running transaction this method allow to define whether or not a local cache should be used.- See Also:
isTxCacheEnabled()
-
attach
public void attach(java.lang.Object objectToAttach)
-
dettach
public boolean dettach(java.lang.Object objectToAttach)
-
getAttached
public <T> T getAttached(java.lang.Class<T> classOfAttachedObject)
-
-