public class DbTransaction extends Object implements Serializable
| Constructor and Description |
|---|
DbTransaction(Db db,
String txName,
boolean fromRemote)
Creates a transaction.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToUpdateCount(int count)
Add to updateCount.
|
int |
decrementTxLevel()
Decrements the transaction level.
|
Collection<CommitTxRunnable> |
getCommitTxRunnables()
Gets the currently registered commit runnables.
|
long |
getCreationTime()
Gets the epochal creation time in ms.
|
Collection<PersistenceVisitor> |
getPersistenceVisitors()
Gets the currently registered persistence visitors.
|
Collection<RollbackTxRunnable> |
getRollbackTxRunnables()
Gets the currently registered rollback runnables.
|
Db |
getSession()
Gets the db.
|
int |
getTxLevel()
Gets the nesting level.
|
String |
getTxName()
Gets the transaction name.
|
long |
getTxNumber()
Gets the transaction number.
|
AbstractDbObject<?> |
getTxObject()
Gets the optional transaction object.
|
long |
getTxVoucher()
Gets the transaction voucher.
|
int |
getUpdateCount()
Gets the number of objects modified since the last begin().
|
int |
incrementTxLevel()
Increments the transaction level.
|
void |
invalidateTxLevel()
Marks the txLevel invalid.
|
void |
invokeCommitTxRunnables()
Executes all commit runnables and removes them.
|
void |
invokeRollbackTxRunnables()
Executes all rollback runnables and removes them.
|
boolean |
isPersistenceOperationAllowed(AbstractDbObject<?> object,
char modType)
Checks whether a persistence operation is allowed.
This is determined by consulting the PersistenceVisitors. |
boolean |
isTxLevelValid()
Returns whether the txLevel is valid.
|
DbTransactionHandle |
registerCommitTxRunnable(CommitTxRunnable commitRunnable)
Registers a
CommitTxRunnable to be invoked just before
committing a transaction. |
DbTransactionHandle |
registerPersistenceVisitor(PersistenceVisitor visitor)
Registers a
PersistenceVisitor to be invoked just before
performing a persistence operation. |
DbTransactionHandle |
registerRollbackTxRunnable(RollbackTxRunnable rollbackRunnable)
Registers a
RollbackTxRunnable to be invoked just before
rolling back a transaction. |
void |
setSession(Db db)
Sets the db.
|
void |
setTxObject(AbstractDbObject<?> txObject)
Sets the optional transaction object.
By default, whenever a transaction is initiated by a persistence operation of a PDO, that object becomes the "parent" of the transaction. The txObject is mainly used for logging and enhanced auditing (partial history) during transactions. |
String |
toString() |
CommitTxRunnable |
unregisterCommitTxRunnable(DbTransactionHandle handle)
Unregisters a
CommitTxRunnable. |
PersistenceVisitor |
unregisterPersistenceVisitor(DbTransactionHandle handle)
Unegisters a
PersistenceVisitor. |
RollbackTxRunnable |
unregisterRollbackTxRunnable(DbTransactionHandle handle)
Unregisters a
RollbackTxRunnable. |
public void setSession(Db db)
Used after transferring from server to client.
db - the new dbpublic Db getSession()
public long getCreationTime()
public int getUpdateCount()
public void addToUpdateCount(int count)
count - the number of updates to addpublic String getTxName()
public long getTxNumber()
public int getTxLevel()
public void invalidateTxLevel()
Will suppress any checks and warnings.
public boolean isTxLevelValid()
public int incrementTxLevel()
public int decrementTxLevel()
public long getTxVoucher()
public void setTxObject(AbstractDbObject<?> txObject)
txObject is mainly used for logging and enhanced auditing (partial history) during transactions.
The txObject is cleared at the end of the transaction.txObject - the transaction object, null to clearpublic AbstractDbObject<?> getTxObject()
public DbTransactionHandle registerPersistenceVisitor(PersistenceVisitor visitor)
PersistenceVisitor to be invoked just before
performing a persistence operation.visitor - the visitor to registerpublic PersistenceVisitor unregisterPersistenceVisitor(DbTransactionHandle handle)
PersistenceVisitor.handle - the visitor's handle to unregisterpublic Collection<PersistenceVisitor> getPersistenceVisitors()
public DbTransactionHandle registerCommitTxRunnable(CommitTxRunnable commitRunnable)
CommitTxRunnable to be invoked just before
committing a transaction.commitRunnable - the runnable to registerpublic CommitTxRunnable unregisterCommitTxRunnable(DbTransactionHandle handle)
CommitTxRunnable.handle - the runnable's handle to unregisterpublic Collection<CommitTxRunnable> getCommitTxRunnables()
public DbTransactionHandle registerRollbackTxRunnable(RollbackTxRunnable rollbackRunnable)
RollbackTxRunnable to be invoked just before
rolling back a transaction.rollbackRunnable - the runnable to registerpublic RollbackTxRunnable unregisterRollbackTxRunnable(DbTransactionHandle handle)
RollbackTxRunnable.handle - the runnable's handle to unregisterpublic Collection<RollbackTxRunnable> getRollbackTxRunnables()
public void invokeCommitTxRunnables()
public void invokeRollbackTxRunnables()
public boolean isPersistenceOperationAllowed(AbstractDbObject<?> object, char modType)
PersistenceVisitors.object - the persistence objectmodType - the modification typeregisterPersistenceVisitor(org.tentackle.persist.PersistenceVisitor)Copyright © 2016 Krake Softwaretechnik. All rights reserved.