Package st.orm

Record Class TransactionOptions

java.lang.Object
java.lang.Record
st.orm.TransactionOptions
Record Components:
propagation - how the block relates to an already active transaction.
isolation - the isolation level.
timeoutSeconds - the transaction timeout in seconds, counted from the start of the block. 0 means no time is left: the block's first statement is refused with TransactionTimedOutException. null inherits the surrounding default, and no timeout applies where none is set.
readOnly - whether the transaction is read-only.

public record TransactionOptions(@Nullable TransactionPropagation propagation, @Nullable TransactionIsolation isolation, @Nullable Integer timeoutSeconds, @Nullable Boolean readOnly) extends Record
Options for a transactional block. A null component means the option is inherited from the surrounding defaults: the thread-scoped options, then the global options, then the baseline (TransactionPropagation.REQUIRED, provider-default isolation and timeout, read-write).
Since:
1.13
  • Constructor Details

    • TransactionOptions

      public TransactionOptions(@Nullable TransactionPropagation propagation, @Nullable TransactionIsolation isolation, @Nullable Integer timeoutSeconds, @Nullable Boolean readOnly)
      Creates an instance of a TransactionOptions record class.
      Parameters:
      propagation - the value for the propagation record component
      isolation - the value for the isolation record component
      timeoutSeconds - the value for the timeoutSeconds record component
      readOnly - the value for the readOnly record component
  • Method Details

    • defaults

      public static TransactionOptions defaults()
      Options with every field inherited from the surrounding defaults.
    • withPropagation

      public TransactionOptions withPropagation(TransactionPropagation propagation)
    • withIsolation

      public TransactionOptions withIsolation(TransactionIsolation isolation)
    • withTimeoutSeconds

      public TransactionOptions withTimeoutSeconds(int timeoutSeconds)
      Returns these options with the given timeout, in seconds from the start of the block. 0 means no time is left, so the block's first statement is refused with TransactionTimedOutException; a block without a timeout leaves the option unset rather than passing a value for it.
      Parameters:
      timeoutSeconds - the transaction timeout in seconds; 0 or more.
      Returns:
      the options with the timeout set.
    • withReadOnly

      public TransactionOptions withReadOnly(boolean readOnly)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • propagation

      public @Nullable TransactionPropagation propagation()
      Returns the value of the propagation record component.
      Returns:
      the value of the propagation record component
    • isolation

      public @Nullable TransactionIsolation isolation()
      Returns the value of the isolation record component.
      Returns:
      the value of the isolation record component
    • timeoutSeconds

      public @Nullable Integer timeoutSeconds()
      Returns the value of the timeoutSeconds record component.
      Returns:
      the value of the timeoutSeconds record component
    • readOnly

      public @Nullable Boolean readOnly()
      Returns the value of the readOnly record component.
      Returns:
      the value of the readOnly record component