Class ReadOnlyClause

java.lang.Object
org.litebridgedb.orm.api.tx.ReadOnlyClause

public final class ReadOnlyClause extends Object
  • Constructor Details

  • Method Details

    • isolation

      public TransactionContextTerminal 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
    • begin

      public Transaction begin()
      Begins a new transaction for the current thread.

      This method should be called before performing operations that need to be executed within a transactional context. It ensures that subsequent database interactions are part of the same transaction until it is either committed or rolled back.

      This method may be called multiple times (nested).

      Returns:
      a Transaction auto-closeable, suitable for use in a try-with-resources statement.
      Throws:
      TransactionException - if an error occurs during starting the transaction
    • execute

      public void execute(Runnable runnable)
      Executes a given Runnable within the context of a transaction.

      This method begins a new transaction, executes the provided Runnable, and commits the transaction if no exception occurs. In case of an exception, the transaction is rolled back, and a TransactionException is thrown.

      Parameters:
      runnable - the Runnable containing the operations to be executed within the transactional context
      Throws:
      TransactionException - if an error occurs during execution or if the transaction is rolled back due to an exception