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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With