docs/api/exposed-jdbc/org.jetbrains.exposed.v1.jdbc.transactions/suspend-transaction.html
suspend fun <T> suspendTransaction(db: Database? = null, transactionIsolation: Int? = db?.transactionManager?.defaultIsolationLevel, readOnly: Boolean? = db?.transactionManager?.defaultReadOnly, statement: suspend JdbcTransaction.() -> T): T
Creates a suspendable 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).
Note This function catches all throwables (including errors) to ensure proper transaction rollback and resource cleanup, even in exceptional circumstances.
The final result of the statement block.
db
Database to use for the transaction. Defaults to null.
transactionIsolation
Transaction isolation level. Defaults to db.transactionManager.defaultIsolationLevel.
readOnly
Whether the transaction should be read-only. Defaults to db.transactionManager.defaultReadOnly.
If no database is available
If a database error occurs and retry attempts are exhausted
If any other error occurs during execution
Generated by Dokka © 2026 Copyright