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.0means no time is left: the block's first statement is refused withTransactionTimedOutException.nullinherits 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 Summary
ConstructorsConstructorDescriptionTransactionOptions(@Nullable TransactionPropagation propagation, @Nullable TransactionIsolation isolation, @Nullable Integer timeoutSeconds, @Nullable Boolean readOnly) Creates an instance of aTransactionOptionsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic TransactionOptionsdefaults()Options with every field inherited from the surrounding defaults.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable TransactionIsolationReturns the value of theisolationrecord component.@Nullable TransactionPropagationReturns the value of thepropagationrecord component.@Nullable BooleanreadOnly()Returns the value of thereadOnlyrecord component.@Nullable IntegerReturns the value of thetimeoutSecondsrecord component.final StringtoString()Returns a string representation of this record class.withIsolation(TransactionIsolation isolation) withPropagation(TransactionPropagation propagation) withReadOnly(boolean readOnly) withTimeoutSeconds(int timeoutSeconds) Returns these options with the given timeout, in seconds from the start of the block.
-
Constructor Details
-
TransactionOptions
public TransactionOptions(@Nullable TransactionPropagation propagation, @Nullable TransactionIsolation isolation, @Nullable Integer timeoutSeconds, @Nullable Boolean readOnly) Creates an instance of aTransactionOptionsrecord class.- Parameters:
propagation- the value for thepropagationrecord componentisolation- the value for theisolationrecord componenttimeoutSeconds- the value for thetimeoutSecondsrecord componentreadOnly- the value for thereadOnlyrecord component
-
-
Method Details
-
defaults
Options with every field inherited from the surrounding defaults. -
withPropagation
-
withIsolation
-
withTimeoutSeconds
Returns these options with the given timeout, in seconds from the start of the block.0means no time is left, so the block's first statement is refused withTransactionTimedOutException; a block without a timeout leaves the option unset rather than passing a value for it.- Parameters:
timeoutSeconds- the transaction timeout in seconds;0or more.- Returns:
- the options with the timeout set.
-
withReadOnly
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
propagation
Returns the value of thepropagationrecord component.- Returns:
- the value of the
propagationrecord component
-
isolation
Returns the value of theisolationrecord component.- Returns:
- the value of the
isolationrecord component
-
timeoutSeconds
Returns the value of thetimeoutSecondsrecord component.- Returns:
- the value of the
timeoutSecondsrecord component
-
readOnly
Returns the value of thereadOnlyrecord component.- Returns:
- the value of the
readOnlyrecord component
-