transaction

fun <T> transaction(db: Database? = null, statement: Transaction.() -> T): T

Creates a transaction then calls the statement block with this transaction as its receiver and returns the result.

Note If the database value db is not set, the value used will be either the last Database instance created or the value associated with the parent transaction (if this function is invoked in an existing transaction).

Return

The final result of the statement block.

Samples

org.jetbrains.exposed.sql.tests.h2.MultiDatabaseTest.testTransactionWithDatabase
fun <T> transaction(transactionIsolation: Int, readOnly: Boolean = false, db: Database? = null, statement: Transaction.() -> T): T

Creates a transaction with the specified transactionIsolation and readOnly settings, then calls the statement block with this transaction as its receiver and returns the result.

Note If the database value db is not set, the value used will be either the last Database instance created or the value associated with the parent transaction (if this function is invoked in an existing transaction).

Return

The final result of the statement block.

Samples

org.jetbrains.exposed.sql.tests.shared.ConnectionTimeoutTest.testTransactionRepetitionWithDefaults