DatabaseUpdateQueryBuilder

internal class DatabaseUpdateQueryBuilder(jdbcTemplate: JdbcTemplate, kotlinToPostgresConverter: KotlinToPostgresConverter, rowMappers: RowMappers, table: String) : AbstractQueryBuilder<UpdateQueryBuilder> , UpdateQueryBuilder

Internal implementation of UpdateQueryBuilder for building SQL UPDATE statements.

Constructors

Link copied to clipboard
constructor(jdbcTemplate: JdbcTemplate, kotlinToPostgresConverter: KotlinToPostgresConverter, rowMappers: RowMappers, table: String)

Properties

Link copied to clipboard
protected open override val canReturnResultsByDefault: Boolean = false
Link copied to clipboard
val jdbcTemplate: JdbcTemplate
Link copied to clipboard
protected var recursiveWith: Boolean
Link copied to clipboard
protected var returningClause: String?
Link copied to clipboard
Link copied to clipboard
protected val table: String?
Link copied to clipboard

Functions

Link copied to clipboard
open override fun asStep(): StepBuilderMethods

Converts this builder to a StepBuilder, which enables lazy execution within a transaction. Returns a wrapper with terminal methods that create TransactionStep instead of executing the query.

Link copied to clipboard
open override fun asStream(fetchSize: Int): StreamingTerminalMethods
Link copied to clipboard
open override fun async(scope: CoroutineScope, ioDispatcher: CoroutineDispatcher): AsyncTerminalMethods
Link copied to clipboard
protected fun buildReturningClause(): String

Builds the SQL fragment for the RETURNING clause.

Link copied to clipboard
open override fun buildSql(): String

Builds the final SQL query based on the builder's state. Must be implemented by each concrete builder class.

Link copied to clipboard
protected fun buildWithClause(): String

Creates a formatted SQL fragment for the WITH clause based on added queries. Each CTE is on a new line for readability.

Link copied to clipboard
open override fun copy(): DatabaseUpdateQueryBuilder
Link copied to clipboard

Copies state from another builder of the same type. Used by copy() methods in derived classes.

Link copied to clipboard
fun execute(params: Map<String, Any?>): DataResult<Int>

Executes a modifying query (without RETURNING) and returns the number of affected rows. Throws an exception if a RETURNING clause was used - in that case, use toList(), toSingle(), etc. methods instead.

protected fun <R> execute(sql: String, params: Map<String, Any?>, action: (positionalSql: String, positionalParams: List<Any?>) -> DataResult<R>): DataResult<R>

Generic function for executing queries, wrapping logic in error handling, type conversion, and logging.

Link copied to clipboard
open override fun from(tables: String): UpdateQueryBuilder
Link copied to clipboard

Marks the WITH clause as recursive.

Link copied to clipboard
fun returning(vararg columns: String): UpdateQueryBuilder

Adds a RETURNING clause to the modifying query (INSERT, UPDATE, DELETE).

Link copied to clipboard
open override fun setExpression(column: String, value: String): UpdateQueryBuilder
Link copied to clipboard
open override fun setExpressions(values: Map<String, String>): UpdateQueryBuilder
Link copied to clipboard
open override fun setValue(column: String): UpdateQueryBuilder
Link copied to clipboard
open override fun setValues(values: List<String>): UpdateQueryBuilder
open override fun setValues(values: Map<String, Any?>): UpdateQueryBuilder
Link copied to clipboard
fun <T> toColumn(targetType: KType, params: Map<String, Any?>): DataResult<List<T>>

Executes the query and returns a list of values from the first column of all rows.

Link copied to clipboard
fun <T> toField(targetType: KType, params: Map<String, Any?>): DataResult<T>

Executes the query and returns the value from the first column of the first row.

Link copied to clipboard
fun <T> toFieldStrict(targetType: KType, params: Map<String, Any?>): DataResult<T>

Executes the query and returns the value from the first column of the first row. Always fails on empty result.

Link copied to clipboard
fun toList(params: Map<String, Any?>): DataResult<List<Map<String, Any?>>>

Executes the query and returns a list of rows as List<Map<String, Any?>>.

Link copied to clipboard
fun <T> toListOf(kType: KType, params: Map<String, Any?>): DataResult<List<T>>

Executes the query and maps results to a list of objects of the given type.

Link copied to clipboard
fun toSingle(params: Map<String, Any?>): DataResult<Map<String, Any?>?>

Executes the query and returns a single row as Map<String, Any?>?.

Link copied to clipboard
fun <T> toSingleOf(kType: KType, params: Map<String, Any?>): DataResult<T>

Executes the query and maps the result to a single object of the given type.

Link copied to clipboard

Executes the query and returns the first row. Always fails on empty result.

Link copied to clipboard
fun toSql(): String

Returns the generated SQL string without executing the query.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun where(condition: String): UpdateQueryBuilder
Link copied to clipboard
fun with(name: String, query: String): UpdateQueryBuilder

Adds a query to the WITH clause (Common Table Expression).