I am evaluating using JOOQ in our solution where we expose data using REST API and checking if the following feature can use jooq's seekAfter and seekBefore api.
suppose i have a table like
CREATE TABLE Test (
Id Int NOT NULL PRIMARY KEY,
Sid varchar(34) NOT NULL,
....
)
We want to do paging using the Id field, but don't want to expose it to the user. We hand out next and previous paging arguments as tokens as part of response.
currently we are building query like
SELECT ... FROM Test WHERE Id > (SELECT Id FROM Test WHERE Sid=?) LIMIT 10;
Is it possible to give it an expression to jooq's seek api instead of literal values ?
You could do something along the lines of this:
// Assuming this static import:
import static org.jooq.impl.DSL.*;
DSL.using(configuration)
.select()
.from(TEST)
.orderBy(TEST.ID)
.seekAfter(field(select(TEST.ID).from(TEST).where(TEST.SID.eq(sid))))
.limit(10)
.fetch();
Essentially, this is wrapping a Select<? extends Record1<T>> type in a Field<T> type with DSL.field(Select)