Back to Exposed

R2dbcTransaction

docs/api/exposed-r2dbc/org.jetbrains.exposed.v1.r2dbc/-r2dbc-transaction/index.html

1.2.018.0 KB
Original Source

R2dbcTransaction

open class R2dbcTransaction(transactionImpl: R2dbcTransactionInterface) : Transaction, R2dbcTransactionInterface

Class representing a unit block of work that is performed on a database using an R2DBC driver.

MembersMembers & Extensions

Constructors

R2dbcTransaction

Link copied to clipboard

constructor(transactionImpl: R2dbcTransactionInterface)

Types

Companion

Link copied to clipboard

object Companion

Properties

currentStatement

Link copied to clipboard

var currentStatement: R2dbcPreparedStatementApi?

The currently executing statement.

db

Link copied to clipboard

override val db: R2dbcDatabase

debug

Link copied to clipboard

var debug: Boolean

defaultLogger

Link copied to clipboard

val defaultLogger: CompositeSqlLogger

A CompositeSqlLogger containing any SqlLogger instances that are implicitly added to a new transaction.

duration

Link copied to clipboard

var duration: Long

id

Link copied to clipboard

val id: String

maxAttempts

Link copied to clipboard

var maxAttempts: Int

The maximum amount of attempts that will be made to perform this transaction block.

maxRetryDelay

Link copied to clipboard

var maxRetryDelay: Long

The maximum number of milliseconds to wait before retrying this transaction if an R2dbcException happens.

minRetryDelay

Link copied to clipboard

var minRetryDelay: Long

The minimum number of milliseconds to wait before retrying this transaction if an R2dbcException happens.

outerTransaction

Link copied to clipboard

open override val outerTransaction: R2dbcTransaction?

queryTimeout

Link copied to clipboard

var queryTimeout: Int?

readOnly

Link copied to clipboard

open override val readOnly: Boolean

statementCount

Link copied to clipboard

var statementCount: Int

statements

Link copied to clipboard

val statements: StringBuilder

statementStats

Link copied to clipboard

val statementStats: HashMap<String, Pair<Int, Long>>

transactionId

Link copied to clipboard

val transactionId: String

transactionIsolation

Link copied to clipboard

open override val transactionIsolation: IsolationLevel?

The transaction isolation level of the transaction, which may differ from the set database level.

transactionManager

Link copied to clipboard

open override val transactionManager: R2dbcTransactionManager

warnLongQueriesDuration

Link copied to clipboard

var warnLongQueriesDuration: Long?

Functions

addLogger

Link copied to clipboard

override fun addLogger(vararg logger: SqlLogger): CompositeSqlLogger

clearExecutedStatements

Link copied to clipboard

fun clearExecutedStatements()

Clears all previously executed statements and resets or releases any used database and/or driver resources.

close

Link copied to clipboard

open suspend override fun close()

Closes the transaction and releases any savepoints.

commit

Link copied to clipboard

open suspend override fun commit()

Saves all changes since the last commit or rollback operation.

connection

Link copied to clipboard

open suspend override fun connection(): R2dbcExposedConnection<*>

Retrieves the database connection used by the transaction.

exec

Link copied to clipboard

suspend fun <T> exec(stmt: SuspendExecutable<T, *>): T?

Executes the provided Statement object and returns the generated value.

suspend fun <T, R> exec(stmt: SuspendExecutable<T, *>, body: suspend Statement<T>.(T) -> R): R?

Executes the provided Statement object, retrieves the generated value, then calls the specified function body with this generated value as its argument and returns its result.

suspend fun exec(stmt: String, args: Iterable<Pair<IColumnType<*>, Any?>> = emptyList(), explicitStatementType: StatementType? = null)

suspend fun <T : Any> exec(stmt: String, args: Iterable<Pair<IColumnType<*>, Any?>> = emptyList(), explicitStatementType: StatementType? = null, transform: (Row) -> T?): Flow<T?>?

Executes the provided statement exactly, using the supplied args to set values to question mark placeholders (if applicable).

execInBatch

Link copied to clipboard

suspend fun execInBatch(stmts: List<String>)

Provided statements will be executed in a batch. Select statements are not supported as it's impossible to return multiple results.

execQuery

Link copied to clipboard

suspend fun <R> execQuery(query: SuspendExecutable<ResultApi, *>, body: suspend Statement<ResultApi>.(R2dbcResult) -> R): R?

Executes the provided query object, retrieves the generated result wrapped as a R2dbcResult, then calls the specified function body with this generated value as its argument and returns its result.

explain

Link copied to clipboard

fun R2dbcTransaction.explain(analyze: Boolean = false, options: String? = null, body: StatementBuilder.() -> Statement<*>): ExplainSuspendExecutable

Creates an ExplainQuery using the EXPLAIN keyword, which obtains information about a statement execution plan.

fullIdentity

Link copied to clipboard

fun fullIdentity(column: Column<*>): String

getOrCreate

Link copied to clipboard

fun <T : Any> getOrCreate(key: Key<T>, init: () -> T): T

getUserData

Link copied to clipboard

fun <T : Any> getUserData(key: Key<T>): T?

identity

Link copied to clipboard

fun identity(column: Column<*>): String

fun identity(table: Table): String

putUserData

Link copied to clipboard

fun <T : Any> putUserData(key: Key<T>, value: T)

registerInterceptor

Link copied to clipboard

fun registerInterceptor(interceptor: StatementInterceptor): Boolean

Adds the specified StatementInterceptor to act on this transaction.

fun registerInterceptor(interceptor: SuspendStatementInterceptor): Boolean

Adds the specified SuspendStatementInterceptor to act on this transaction.

removeUserData

Link copied to clipboard

fun <T : Any> removeUserData(key: Key<T>): Any?

rollback

Link copied to clipboard

open suspend override fun rollback()

Reverts all changes since the last commit or rollback operation, or to the last set savepoint, if applicable.

unregisterInterceptor

Link copied to clipboard

fun unregisterInterceptor(interceptor: StatementInterceptor): Boolean

Removes the specified StatementInterceptor from acting on this transaction.

fun unregisterInterceptor(interceptor: SuspendStatementInterceptor): Boolean

Removes the specified SuspendStatementInterceptor from acting on this transaction.

withDataBaseLock

Link copied to clipboard

suspend fun <T> R2dbcTransaction.withDataBaseLock(body: () -> T)

Creates table with name "busy" (if not present) and single column to be used as "synchronization" point. Table wont be dropped after execution.

Generated by Dokka © 2026 Copyright