public interface Transaction
Modifier and Type | Method and Description |
---|---|
void |
commit()
This will commit the transaction.
|
void |
finallyRollbackIfNotCommitted()
This is designed to be called in a top level finally block and it will attempt to rollback the transaction IF it
has not already been committed.
|
NestedConnection |
getNestedConnection()
This will return the connection used by this transaction, in a transaction-safe wrapper using
NestedConnection |
boolean |
isNewTransaction()
Returns if this is a new transaction.
|
void |
rollback()
This will rollback the transaction.
|
void |
runAfterSuccessfulCommit(Runnable runnable)
This will enqueue a runnable that will be run if the transaction successfully commits.
|
void commit() throws TransactionRuntimeException
TransactionRuntimeException
- if the transaction cannot be commitedvoid rollback() throws TransactionRuntimeException
TransactionRuntimeException
- if the transaction cannot be rollbackedvoid finallyRollbackIfNotCommitted()
Note it DOES NOT throw a {@link TransactionRuntimeException) if the roll back cannot be performed. Since this is intended to be inside a finally block it most likely to late to know about this you probably dont want to do anything since rollback hasnt worked either. So it logs this condition is an ignores it to make calling code more simple.
boolean isNewTransaction()
Calls to commit for a nested transaction effectively do nothing relying on the outer transaction to perform the commit.
Calls to rollback for a nested transaction mark the outer transaction as requiring to be rolled back. The outer transaction will eventually rollback, whether commit or rollback is eventually called.
commit()
or rollback()
will actually do anythingvoid runAfterSuccessfulCommit(@Nonnull Runnable runnable)
runnable
- the code to run if the transaction commits successfullyNestedConnection getNestedConnection()
NestedConnection
Used as a safety measure against devs calling commit() close() etc
Copyright © 2002-2019 Atlassian. All Rights Reserved.