English | 简体中文

api-docs / me.liuwj.ktorm.database

Package me.liuwj.ktorm.database

Entry of Ktorm framework, providing basic features of connection and transaction management.

Types

NameSummary

Database

class Database

The entry class of Ktorm, represents a physical database, used to manage connections and transactions.

JdbcTransactionManager

class JdbcTransactionManager : TransactionManager

TransactionManager implementation based on JDBC.

SpringManagedTransactionManager

class SpringManagedTransactionManager : TransactionManager

TransactionManager implementation that delegates all transactions to the Spring framework.

SqlDialect

interface SqlDialect

Representation of a SQL dialect.

Transaction

interface Transaction : Closeable

Representation of a transaction.

TransactionIsolation

enum class TransactionIsolation

Enum class represents transaction isolation levels, wrapping the TRANSACTION_XXX constants
defined in the Connection interface.

TransactionManager

interface TransactionManager

Transaction manager abstraction used to manage database connections and transactions.

Exceptions

NameSummary

DialectFeatureNotSupportedException

class DialectFeatureNotSupportedException : 
    UnsupportedOperationException

Thrown to indicate that a feature is not supported by the current dialect.

Functions

NameSummary

prepareStatement

fun <T> SqlExpression.prepareStatement(
    autoGeneratedKeys: Boolean = false,
    func: (PreparedStatement) -> T
): T

Format the current SqlExpression to a SQL string with its execution arguments, then create
a PreparedStatement from the global database using the SQL string and execute the specific
callback function with it. After the callback function completes, the statement will be
closed automatically.

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.

useConnection

fun <T> useConnection(func: (Connection) -> T): T

Obtain a connection from Database.global and invoke the callback function with it.

useTransaction

fun <T> useTransaction(
    isolation: TransactionIsolation = TransactionIsolation.REPEATABLE_READ,
    func: (Transaction) -> T
): T

Execute the specific callback function in a transaction of Database.global and returns its result if the
execution succeeds, otherwise, if the execution fails, the transaction will be rollback.