Package com.pyranid
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 TypeMethodDescriptionvoid
addPostTransactionOperation
(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.void
Rolls back to the provided transaction savepoint.void
setRollbackOnly
(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
Rolls back to the provided transaction savepoint.- Parameters:
savepoint
- the savepoint to roll back to
-
isRollbackOnly
Should this transaction be rolled back upon completion?Default value is
false
.- Returns:
true
if this transaction should be rolled back,false
otherwise
-
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:
true
if the post-transaction operation was removed,false
otherwise
-
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
-