Reputation: 3660
Can i use jooq to create queries for jasper report?
I mean query like this
select something from table where field=$P{someparameter}
the problem is the $P{someparameter}
in the generated sql.
To be clear I just need the generated sql query.
Upvotes: 1
Views: 349
Reputation: 220977
You can always resort to what jOOQ calls "plain SQL", if there is some vendor-specific SQL expression that you would like to include. In your case, I'm guessing that the following might be sufficient for you:
Select<?> select =
DSL.using(configuration)
.select(TABLE.SOMETHING)
.from(TABLE)
.where(TABLE.FIELD.eq(DSL.field("$P{{someparameter}}", TABLE.FIELD.getDataType())));
Note that you'll have to "escape" the curly braces, as curly braces have a meaning in jOOQ's plain SQL template language.
You can then extract the SQL string like this:
String sql = select.getSQL();
And possibly extract the bind values as well:
List<Object> bindings = select.getBindValues();
Upvotes: 1