SelectQuery
A SELECT under construction.
Every clause takes SQL and passes it through: from("legions l JOIN provinces p ON l.province_id = p.id") is written out because that is the join, not because the builder has a way to describe joins. What the builder does is the mechanical part - the keywords, the order they go in, and above all the clauses that disappear when they have nothing to say, which is what makes a filter assembled at runtime bearable.
val senators = db.select("id", "cognomen", "province_id")
.from("senate")
.where(filter.sql) // null or empty leaves out the WHERE entirely
.orderBy("cognomen")
.page(page = 0, size = 20)
.fetchObjects<Senator>(filter.params)The terminal methods come from RunnableQuery, so parameters are supplied there and never carried here.
Properties
Functions
Switches this query to the result style: every terminal on the returned object hands back a DataResult instead of throwing.
Turns this query into a step of a TransactionPlan instead of something to run now.
Returns an independent copy, so that variants can be built from a shared base.
Carries registered converters into a builder's copy(), alongside whatever clauses it copies.
As fetchField, but the query must return exactly one row rather than at most one.
Runs the query and returns its single row, throwing where the count was anything but one.
Locks the selected rows with FOR UPDATE, for a read-then-write that must not race.
Sets the FROM clause, as SQL.
Sets the FROM clause to a subquery, parenthesised and optionally aliased.
Sets the GROUP BY columns. null or blank leaves the clause out.
Sets the HAVING condition, which requires a GROUP BY. null or blank leaves the clause out.
Sets LIMIT. null leaves it out.
Sets OFFSET.
Sets the ORDER BY clause. null or blank leaves the clause out.
Sets LIMIT and OFFSET together from a page number and a page size.
Builds the driver query a terminal is about to run, with this query's own converters on it.
Marks the WITH clause RECURSIVE.
Registers a ParameterConverter for this query and nothing else.
Registers a ResultConverter for this query and nothing else.
Sets the WHERE condition. null or blank leaves the clause out.
Adds a common table expression. Call it more than once for more than one.