FetchSpec

interface FetchSpec(source)

Specifies how to execute the built SQL and retrieve the results.

Each terminal operation (singleMap, single, list, sequence, rowsUpdated, generatedValues, ...) executes the statement when invoked.

Rows are mapped to the specified type as follows: simple scalar types (numbers, strings, date/time types, ...) are read from the first column of the row, while other types (e.g. data classes) are mapped by matching column names to constructor parameters.

Functions

Link copied to clipboard
abstract fun fetchSize(fetchSize: Int): KueryBlockingClient.FetchSpec

Sets the fetch size (the number of rows fetched from the database at a time) to use when executing this query.

Link copied to clipboard
abstract fun generatedValues(vararg columns: String): Map<String, Any>

Executes the statement and returns one row of values generated on the database side, such as an auto-increment ID. The map keys and value types are those reported by the configured driver and may differ from the requested column names.

Link copied to clipboard
abstract fun <T : Any> list(returnType: KClass<T>): List<T>

Executes the query and returns all rows converted to returnType.

Link copied to clipboard

Executes the query and returns all rows converted to T.

Link copied to clipboard
abstract fun listMap(): List<Map<String, Any?>>

Executes the query and returns all rows as a list of maps keyed by column name.

Link copied to clipboard
abstract fun maxRows(maxRows: Int): KueryBlockingClient.FetchSpec

Sets the maximum number of rows to return from this query.

Link copied to clipboard
abstract fun queryTimeoutSeconds(queryTimeoutSeconds: Int): KueryBlockingClient.FetchSpec

Sets the query timeout (in seconds) for this query.

Link copied to clipboard
abstract fun rowsUpdated(): Long

Executes the statement (typically INSERT, UPDATE, or DELETE) and returns the number of affected rows.

Link copied to clipboard
abstract fun <T : Any> sequence(returnType: KClass<T>): CloseableSequence<T>

Executes the query and returns each row converted to returnType, as a sequence that streams rows without accumulating them all in memory.

Link copied to clipboard

Executes the query and returns each row converted to T, as a sequence that streams rows without accumulating them all in memory.

Link copied to clipboard

Executes the query and returns each row as a map keyed by column name, as a sequence that streams rows without accumulating them all in memory.

Link copied to clipboard
abstract fun <T : Any> single(returnType: KClass<T>): T

Executes the query and returns exactly one row converted to returnType.

Link copied to clipboard

Executes the query and returns exactly one row converted to T.

Link copied to clipboard
abstract fun singleMap(): Map<String, Any?>

Executes the query and returns exactly one row as a map keyed by column name.

Link copied to clipboard
abstract fun singleMapOrNull(): Map<String, Any?>?

Executes the query and returns at most one row as a map keyed by column name, or null if the query returns no rows.

Link copied to clipboard
abstract fun <T : Any> singleOrNull(returnType: KClass<T>): T?

Executes the query and returns at most one row converted to returnType, or null if the query returns no rows.

Link copied to clipboard

Executes the query and returns at most one row converted to T, or null if the query returns no rows.