I need to create a JOOQ SELECT query dynamically based on the set of parameters. I dont know how to append it dynamically. Please help
Thanks in advance.
I need to create a JOOQ SELECT query dynamically based on the set of parameters. I dont know how to append it dynamically. Please help
Thanks in advance.
jOOQ has two types of APIs to construct queries.
The DSL API that allows for creating inline SQL statements in your Java code, e.g.
The "model" API that allows for incremental SQL building. At any time, you can access the "model" API through the
getQuery()
method on a DSL query objectAn example of what you want to do is given in the manual here:
https://www.jooq.org/doc/latest/manual/sql-building/sql-statements/dsl-and-non-dsl/
For instance, optionally adding a join:
Or, optinally adding conditions / predicates:
UPDATE: Given your comments, that's what you're looking for:
Note, you can also use the
Field.compare(Comparator, Object)
methods:For more info, consider the org.jooq.SelectQuery Javadoc