问题
jOOQ runs on generated classes (from database schema). In my apps, there are many tables created while excuting. Then how can I query them using jOOQ? Or can I use something else to do this?
We just use jOOQ to generate SQL, not doing any CRUD operation.
回答1:
While being the main use case for using jOOQ, you do not have to generate any source code with jOOQ. Several users have used jOOQ the way you do, by supplying dynamic table/column names at runtime to Factory methods such as:
- DSL.tableByName(String...)
- DSL.fieldByName(String...)
These methods take care of correctly escaping your schema, table, field, alias names, etc, in order to guarantee SQL syntax correctness and SQL injection protection.
Some related discussions on the jOOQ User Group are here:
- Escaping SQL identifiers
- Intantiating Field and Table by name
- Specifying the alias name for a JOIN
来源:https://stackoverflow.com/questions/11390712/how-to-use-jooq-or-something-else-in-such-condition