Class TransactionOptions
java.lang.Object
com.pyranid.TransactionOptions
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder used to constructTransactionOptions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the diagnostic observer invoked after connection cleanup and all post-transaction hooks.Gets the transaction isolation level.Gets the read-only setting to apply, if any.inthashCode()toString()withIsolation(@NonNull TransactionIsolation isolation) Starts building transaction options with a transaction isolation level.withReadOnly(@Nullable Boolean readOnly) Starts building transaction options with a read-only setting.
-
Method Details
-
withIsolation
public static @NonNull TransactionOptions.Builder withIsolation(@NonNull TransactionIsolation isolation) 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.truerequests a read-only transaction,falserequests a read-write transaction, andnullleaves the connection's read-only state unchanged.- 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.truerequests a read-only transaction,falserequests 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
-
hashCode
-
toString
-