how to use jOOQ (or something else) in such condition

我的未来我决定 提交于 2020-01-16 04:35:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!