Interface TransactionControl

All Superinterfaces:
ConnectionProvider
All Known Subinterfaces:
TransactionManager
All Known Implementing Classes:
DefaultTransactionManager, LitebridgeTransactionManager, Transaction

public interface TransactionControl extends ConnectionProvider
Provides control over the transaction lifecycle, including committing and rolling back transactions. This interface extends 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

    Modifier and Type
    Method
    Description
    void
    Commits the current transaction.
    boolean
    Checks if the current transaction is marked as rollback-only.
    boolean
    Checks if there is an active transaction for the current thread.
    void
    Rolls back the current transaction.

    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 commit
      TransactionException - 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 back
      TransactionException - 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:
      true if a thread-bound transaction is currently active, false otherwise
    • 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:
      true if the transaction is marked for rollback, false otherwise