#20253·jOOQ

Add an inclusive variant of the synthetic SEEK clause (>= instead of >)

Author: mdindofferCreated Sep 18, 2026Updated Sep 21, 2026
LabelsT: EnhancementC: FunctionalityP: LowE: All Editions

Use case

seek() / seekAfter() always render a strictly exclusive predicate:

SELECT * FROM t WHERE (id, code) > (3, 'abc') ORDER BY id, code

There is no way to get the same predicate with >=, i.e. a page that starts at the cursor row rather than after it.

I'm building a keyset-paginated REST API with an optional includeCursorItem flag. The flag exists because of deep-linkable UI state: a user selects a row in a paginated table, the URL is updated to reference that row, and the URL is shared. When the recipient opens it, the table must render the referenced row first, followed by the rest of the page, not just the rows after it. Regular "next page" clicks (or public REST-like API) keep using the exclusive form, so both semantics are needed from the same code path, selected by a boolean.

Possible solution

An inclusive counterpart to the existing methods on SelectSeekStepN, e.g.:

java
DSL.using(configuration)
   .selectFrom(TABLE)
   .orderBy(ID, CODE)
   .seekAfterInclusive(3, "abc")   // or seekInclusive(...)
   .fetch();

rendering:

sql
    SELECT ... FROM table
    WHERE (id, code) >= (3, 'abc')
    ORDER BY id ASC, code ASC

with the same benefits of seek() - nulls, ordering, whatever.

If adding overloads to every SelectSeekStepN arity is too costly, a flag on the seek step, would already solve the use case.

Possible workarounds

SelectSeekStepN only offers seek(), seekAfter() and the deprecated seekBefore(), all exclusive ranges. So the options today are:

  1. Query the cursor row separately and UNION ALL it with an exclusive seek() page. This means an extra query / more complex plan for what is a one-character difference in SQL.
  2. Drop seek() and hand-write the predicate, e.g. row(A, B).ge(row(a, b)). This works, but gives up advantages of seek(), e.g.: ASC/DESC orderings, NULLS FIRST / NULLS LAST handling, and the compile-time check that the cursor tuple degree matches the ORDER BY degree is lost.

jOOQ Version

3.21.7

Database product and version

Postgres 18

Java Version

No response

JDBC / R2DBC driver name and version (include name if unofficial driver)

No response