java - Jooq: Extract value from SortField -
i doing pagination jooq. data ordered multiple fields, 1 of them custom function on field. example, have sortfield this:
dsl.coalesce(table.column, 0).asc()
the final sql like:
select a, b, c table condition order column_a asc, coalesce(table.column, 0) asc
now want value of last record on page. works normal field when using
record.getvalue(field.getname())
but when comes custom field, throws exception says
java.lang.illegalargumentexception: field (coalesce) not contained in row
do have ways value of above coalesce function?
this not specific jooq. sql works way. behaviour got natural because did not select expression:
select a, b, c table condition order column_a asc, coalesce(table.column, 0) asc
will produce 3 columns: a
, b
, , c
. example:
a b c ------------ 1 2 3 4 5 6
in result, there's no column name "coalesce". if want have column name "coalesce" or similar, need project it. in jooq:
field<integer> coalesce = dsl.coalesce(table.column, 0); (record record : dsl.using(configuration) .select(table.a, table.b, table.c, coalesce) .from(table) .where(condition) .orderby(table.a.asc(), coalesce.asc())) system.out.println(record.get(coalesce));
Comments
Post a Comment