Back to Exposed

BlockingExecutable

docs/api/exposed-jdbc/org.jetbrains.exposed.v1.jdbc.statements/-blocking-executable/index.html

1.2.04.5 KB
Original Source

BlockingExecutable

interface BlockingExecutable<out T, S : Statement<T>>

Executable provides a customizable execution mechanism for SQL statements within a transaction.

This interface allows implementing classes to define specific execution logic specific to a JDBC driver and customize how the return value is handled. It is primarily used when fine-grained control over statement execution is required.

For the suspend R2DBC alternative of this interface, see SuspendExecutable provided with a dependency on exposed-r2dbc.

Usage Example:

kotlin
open class BatchUpsertBlockingExecutable( override val statement: BatchUpsertStatement) : BatchInsertBlockingExecutable<BatchUpsertStatement>(statement) { override fun prepared(transaction: JdbcTransaction, sql: String): JdbcPreparedStatementApi { // We must return values from upsert because returned id could be different depending on insert or upsert happened if (!currentDialect.supportsOnlyIdentifiersInGeneratedKeys) { return transaction.connection.prepareStatement(sql, statement.shouldReturnGeneratedValues) } return super.prepared(transaction, sql) }}

Content copied to clipboard

The implemented Executable can be later used in utility functions like Table.batchUpsert().

Type Parameters

T

The return type of the SQL execution result.

S

The type of SQL statement that is executed.

Inheritors

ExplainBlockingExecutable

Query

SetOperation

DeleteBlockingExecutable

InsertBlockingExecutable

InsertSelectBlockingExecutable

MergeBlockingExecutable

ReturningBlockingExecutable

UpdateBlockingExecutable

Members

Properties

isAlwaysBatch

Link copied to clipboard

open val isAlwaysBatch: Boolean

Whether the SQL statement is meant to be performed as part of a batch execution.

statement

Link copied to clipboard

abstract val statement: S

The actual Exposed Statement on which the specific execution logic should be used.

Functions

execute

Link copied to clipboard

open fun execute(transaction: JdbcTransaction): T?

Executes the SQL statement directly in the provided transaction and returns the generated result, or null if either no result was retrieved or if the transaction blocked statement execution.

executeInternal

Link copied to clipboard

abstract fun JdbcPreparedStatementApi.executeInternal(transaction: JdbcTransaction): T?

Determines the exact way that an SQL statement is executed in a transaction and applies any necessary logic before returning the result generated by the executed statement.

prepared

Link copied to clipboard

open fun prepared(transaction: JdbcTransaction, sql: String): JdbcPreparedStatementApi

Uses a transaction connection and an sql string representation to return a precompiled SQL statement, stored as an implementation of JdbcPreparedStatementApi.

Generated by Dokka © 2026 Copyright