Class TransactionContext

java.lang.Object
org.litebridgedb.orm.api.tx.TransactionContextTerminal
org.litebridgedb.orm.api.tx.TransactionContext

public final class TransactionContext extends TransactionContextTerminal
  • Constructor Details

  • Method Details

    • readOnly

      public ReadOnlyClause readOnly()
      Indicates that the transaction should be read-only.

      Read-only transactions are used when the transaction is intended to only read data and not modify it.

      Returns:
      Available clauses for transaction configuration chaining
    • isolation

      public IsolationClause isolation(Isolation level)
      Sets the transaction isolation level for the current thread.

      The isolation level determines the degree of isolation provided for transactions, affecting how changes made by one transaction are visible to other transactions.

      Returns:
      Available clauses for transaction configuration chaining
    • commit

      public void 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

      public void 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