Class TransactionOptions

java.lang.Object
com.pyranid.TransactionOptions

@ThreadSafe public final class TransactionOptions extends Object
Options for a Pyranid-managed transaction.

Use this when transaction behavior differs from the defaults. For example:

database.transaction(
  TransactionOptions.withIsolation(TransactionIsolation.REPEATABLE_READ)
    .readOnly(true)
    .build(),
  () -> {
    // transactional work
  });
Since:
4.2.0
Author:
Mark Allen
  • Method Details

    • withIsolation

      Starts building transaction options with a transaction isolation level.
      Parameters:
      isolation - the desired database transaction isolation level
      Returns:
      a transaction options builder
    • withReadOnly

      Starts building transaction options with a read-only setting.

      true requests a read-only transaction, false requests a read-write transaction, and null leaves the connection's read-only state unchanged. Drivers may reject changes on an open connection. In particular, SQLite's default JDBC configuration and DuckDB require read-only mode to be configured when opening the database connection. Use a separately configured read-only data source and leave this option null to inherit its state.

      Parameters:
      readOnly - read-only setting to apply
      Returns:
      a transaction options builder
    • getIsolation

      Gets the transaction isolation level.
      Returns:
      transaction isolation level
    • getReadOnly

      Gets the read-only setting to apply, if any.

      true requests a read-only transaction, false requests a read-write transaction, and empty leaves the connection's read-only state unchanged.

      Returns:
      read-only setting to apply
    • getCompletionObserver

      Gets the diagnostic observer invoked after connection cleanup and all post-transaction hooks.
      Returns:
      completion observer, if configured
      Since:
      4.8.0
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      Overrides:
      toString in class Object