Hi,
I have been tearing my hair trying to build a query step by step
(conditions, order by, limit etc) based on criteria passed from front-end;
basically building a dynamic query.
I was dancing around SelectSelectSteps, SelectJoinSteps,
SelectConditionSteps ... and was going quite mad. Then I re-read the manual
once again and found a small section talking about Non DSL select queries.
Wow! Things got really easy then on. In a matter of lines I had my
conditions and sorts sorted out.
Now the only issue is to do a select(count(*)) in a similar manner - any
pagination search implementation needs one. The problem is that I cannot
find a way of doing in a non DSL manner.
I tried the following workaround inspired by the manual section "Plain SQL
in JOOQ"; However FactoryOperations (which I need because of a Spring
dependency) doesn't seem to have this method. Any suggestions?
SelectSelectStep cquery = mzFactory.selectCount();
Field<Integer> COUNT = mzFactory.field("count(*) y", Integer.class);
cquery.addSelect(count());
cquery.addFrom(USER_REQUEST);