Class Transaction
java.lang.Object
com.pyranid.Transaction
Represents a database transaction.
Note that commit and rollback operations are controlled internally by Database.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPostTransactionOperation(Consumer<TransactionResult> postTransactionOperation) Adds an operation to the list of operations to be executed when the transaction completes.Creates a transaction savepoint that can be rolled back to viarollback(Savepoint).Gets an unmodifiable list of post-transaction operations.Get the isolation level for this transaction.Should this transaction be rolled back upon completion?removePostTransactionOperation(Consumer<TransactionResult> postTransactionOperation) Removes an operation from the list of operations to be executed when the transaction completes.voidRolls back to the provided transaction savepoint.voidsetRollbackOnly(Boolean rollbackOnly) Sets whether this transaction should be rolled back upon completion.toString()
-
Method Details
-
toString
-
createSavepoint
Creates a transaction savepoint that can be rolled back to viarollback(Savepoint).- Returns:
- a transaction savepoint
-
rollback
-
isRollbackOnly
Should this transaction be rolled back upon completion?Default value is
false.- Returns:
trueif this transaction should be rolled back,falseotherwise
-
setRollbackOnly
Sets whether this transaction should be rolled back upon completion.- Parameters:
rollbackOnly- whether to set this transaction to be rollback-only
-
addPostTransactionOperation
public void addPostTransactionOperation(@Nonnull Consumer<TransactionResult> postTransactionOperation) Adds an operation to the list of operations to be executed when the transaction completes.- Parameters:
postTransactionOperation- the post-transaction operation to add
-
removePostTransactionOperation
@Nonnull public Boolean removePostTransactionOperation(@Nonnull Consumer<TransactionResult> postTransactionOperation) Removes an operation from the list of operations to be executed when the transaction completes.- Parameters:
postTransactionOperation- the post-transaction operation to remove- Returns:
trueif the post-transaction operation was removed,falseotherwise
-
getPostTransactionOperations
Gets an unmodifiable list of post-transaction operations.To manipulate the list, use
addPostTransactionOperation(Consumer)andremovePostTransactionOperation(Consumer).- Returns:
- the list of post-transaction operations
-
getTransactionIsolation
Get the isolation level for this transaction.- Returns:
- the isolation level
-