inTopLevelTransaction

fun <T> inTopLevelTransaction(transactionIsolation: Int, readOnly: Boolean = false, db: Database? = null, outerTransaction: Transaction? = 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 All changes in this transaction will be committed at the end of the statement block, even if it is nested and even if DatabaseConfig.useNestedTransactions is set to false.

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.RollbackTransactionTest.testRollbackWithoutSavepoints