Reputation: 3887
Say for example my function accepts a parameter called 'entityType', and according to that it queries the table entityType_other_stuff
.
Is this possible to implement in JOOQ on runtime?
Upvotes: 3
Views: 2131
Reputation: 221145
The correct way to create dynamic org.jooq.Table
objects by name is to use DSL.table(Name)
as in:
String parameter = "entityType";
Table<?> table = table(name(parameter + "_other_stuff"));
If you use the standard Settings.renderNameStyle
QUOTED
, then the identifier will be quoted and escaped, and thus SQL-injection safe.
For more information, see the manual: https://www.jooq.org/doc/latest/manual/sql-building/names
Upvotes: 4