# JdbcTransaction

open class JdbcTransaction(transactionImpl: JdbcTransactionInterface) : Transaction, JdbcTransactionInterface

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

## Constructors

JdbcTransaction
Link copied to clipboard
constructor(transactionImpl: JdbcTransactionInterface)

## Types

Companion
Link copied to clipboard
object Companion

## Properties

connection
Link copied to clipboard
open override val connection: ExposedConnection<*>

The database connection used by the transaction.

currentStatement
Link copied to clipboard
var currentStatement: JdbcPreparedStatementApi?

The currently executing statement.

db
Link copied to clipboard
override val db: Database
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 SQLException happens.

minRetryDelay
Link copied to clipboard
var minRetryDelay: Long

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

outerTransaction
Link copied to clipboard
open override val outerTransaction: JdbcTransaction?
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: Int

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

transactionManager
Link copied to clipboard
open override val transactionManager: JdbcTransactionManager
warnLongQueriesDuration
Link copied to clipboard
var warnLongQueriesDuration: Long?

## Functions

addLogger
Link copied to clipboard
override fun addLogger(vararg logger: SqlLogger): CompositeSqlLogger
close
Link copied to clipboard
open override fun close()

Closes the transaction and releases any savepoints.

closeExecutedStatements
Link copied to clipboard
fun closeExecutedStatements()

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

commit
Link copied to clipboard
open override fun commit()

Saves all changes since the last commit or rollback operation.

exec
Link copied to clipboard
fun <T> exec(stmt: BlockingExecutable<T, *>): T?

Executes the provided Statement object and returns the generated value.

fun <T, R> exec(stmt: BlockingExecutable<T, *>, body: 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.

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

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

execInBatch
Link copied to clipboard
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
fun <R> execQuery(query: BlockingExecutable<ResultApi, *>, body: Statement<ResultApi>.(ResultSet) -> R): R?

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

explain
Link copied to clipboard
fun JdbcTransaction.explain(analyze: Boolean = false, options: String? = null, body: StatementBuilder.() -> Statement<*>): ExplainBlockingExecutable

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.

removeUserData
Link copied to clipboard
fun <T : Any> removeUserData(key: Key<T>): Any?
rollback
Link copied to clipboard
open 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.

withDataBaseLock
Link copied to clipboard
fun <T> JdbcTransaction.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.

withSuspendTransaction
Link copied to clipboard
suspend fun <T> JdbcTransaction.withSuspendTransaction(context: CoroutineContext? = null, statement: suspend JdbcTransaction.() -> T): T