Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jOOQ addConditions: in SQL question mark appears instead of the value

Tags:

java

sql

jooq

I would like to launch simple code:

SelectQuery query = dsl.select(field ("id"), field("title")).from("dict.models").getQuery();
if (modelId > 0) query.addConditions(field("model_id", SQLDataType.INTEGER).equal(modelId));

But infortunately in getSQL() I can only see:

select id, title from dict.models where model_id = ?

Where is a mistake?

Thanks.

like image 465
Andrey Avatar asked Nov 07 '14 20:11

Andrey


1 Answers

Query.getSQL() generates the SQL statement as it would be generated if you let jOOQ execute a PreparedStatement - with bind variables. The bind variables can be extracted in the right order via Query.getBindValues()

If you want to inline all bind values into the generated SQL, you have various options through the jOOQ API (all equivalent):

  • Using Query.getSQL(ParamType) with ParamType.INLINE
  • Using dsl.renderInlined(QueryPart)
  • Using StatementType.STATIC_STATEMENT in your Settings
like image 58
Lukas Eder Avatar answered Nov 15 '22 05:11

Lukas Eder