English | 简体中文

api-docs / org.ktorm.database / Transaction

Transaction

interface Transaction : Closeable (source code)

Representation of a transaction.

Transactional code can use this interface to retrieve the backend connection, and
to programmatically trigger a commit or rollback (instead of implicit commits and rollbacks
of using Database.useTransaction).

Properties

NameSummary

connection

abstract val connection: Connection

The backend JDBC connection of this transaction.

Functions

NameSummary

close

abstract fun close(): Unit

Close the transaction and release its underlying resources (e.g. the backend connection).

commit

abstract fun commit(): Unit

Commit the transaction.

rollback

abstract fun rollback(): Unit

Rollback the transaction.

Extension Functions

NameSummary

eq

infix fun <T : Any> T.eq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Equal operator, translated to = in SQL.

neq

infix fun <T : Any> T.neq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

notEq

infix fun <T : Any> T.notEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

use

fun <T : AutoCloseable?, R> T.use(block: (T) -> R): R

Execute the given block function on this resource and then close it down correctly whether an exception
is thrown or not.