- All Superinterfaces:
ConnectionProvider
- All Known Subinterfaces:
TransactionManager
- All Known Implementing Classes:
DefaultTransactionManager,LitebridgeTransactionManager,Transaction
ConnectionProvider to offer transaction-specific operations.
Implementations of this interface are expected to manage the transaction lifecycle, ensuring that changes are either committed or rolled back appropriately. They also provide a mechanism to check the status of the transaction for the current thread.
-
Method Summary
Methods inherited from interface org.litebridgedb.db.spi.tx.ConnectionProvider
connection
-
Method Details
-
commit
Commits the current transaction.This method finalises all operations performed during the transaction and applies any changes to the underlying database. After a successful commit, the transaction is no longer active.
- Throws:
IllegalStateException- if there is no active transaction to commitTransactionException- if an error occurs during the commit process
-
rollback
Rolls back the current transaction.This method undoes all changes made during the active transaction. It reverts the state of the underlying data store to the point before the transaction began. After a successful rollback, the transaction is no longer active.
It should be called in cases where the transaction cannot be successfully completed, such as when an error occurs during the operations performed within the transaction.
- Throws:
IllegalStateException- if there is no active transaction to roll backTransactionException- if an error occurs during the rollback process
-
isTransactionActive
boolean isTransactionActive()Checks if there is an active transaction for the current thread.This method determines whether a transaction has been started and is not yet committed or rolled back.
- Returns:
trueif a thread-bound transaction is currently active,falseotherwise
-
isRollbackOnly
boolean isRollbackOnly()Checks if the current transaction is marked as rollback-only. This indicates that the transaction cannot be successfully committed and must be rolled back.- Returns:
trueif the transaction is marked for rollback,falseotherwise
-