TransactionManager

class TransactionManager(val session: OctaviusSession, connection: OctaviusConnection)

A high-level API for managing transactions via scoped blocks.

This manager provides robust block-based transaction scoping, such as required and nested, automatically handling commit, rollback, and savepoints based on the execution result. Within these scopes, the receiver is restricted to OctaviusSessionOperations, preventing manual interference with the transaction lifecycle.

If you need manual, low-level transaction control (e.g., explicit commit(), rollback(), autoCommit manipulation, or manual savepoints), use the methods provided directly on the parent OctaviusSession.

Constructors

Link copied to clipboard
internal constructor(session: OctaviusSession, connection: OctaviusConnection)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
internal fun applySettings(isolation: TransactionIsolationLevel?, readOnly: Boolean, statementTimeout: Duration?, transactionTimeout: Duration?)

Hands the terms this transaction was opened with to its BEGIN, as one statement.

Link copied to clipboard
inline fun <T> nested(isolation: TransactionIsolationLevel? = null, readOnly: Boolean = false, statementTimeout: Duration? = null, transactionTimeout: Duration? = null, crossinline block: OctaviusSessionOperations.() -> T): T

Executes the given block within a nested transaction scope.

Link copied to clipboard
inline fun <T> required(isolation: TransactionIsolationLevel? = null, readOnly: Boolean = false, statementTimeout: Duration? = null, transactionTimeout: Duration? = null, crossinline block: OctaviusSessionOperations.() -> T): T

Executes the given block within a transaction scope.

Link copied to clipboard
internal fun restoreAutoCommit(failure: Throwable?)

Puts auto-commit back once a scope is over, however it ended.

Link copied to clipboard
internal fun warnSettingsIgnored(isolation: TransactionIsolationLevel?, readOnly: Boolean, statementTimeout: Duration?, transactionTimeout: Duration?, scope: String)

Says out loud that a scope asked for terms it is in no position to set.