Can JOOQ be used without code generation?

落花浮王杯 提交于 2019-12-01 15:00:26

问题


I am assessing JOOQ for use in a new system that is still under development. I would like to avoid code generation when the database is being developed along with the application and simply plays a role of a persistent storage for this application. So, the database schema definition is expected to be driven by Java code (table definitions in java).

Is JOOQ appropriate for the above use case? Is there a java DSL for schema definition?


回答1:


Is JOOQ appropriate for the above use case?

Yes, many jOOQ users use only the runtime library without the code generator. Examples can be seen in the getting started guide.

Is there a java DSL for schema definition?

jOOQ wraps JDBC's DatabaseMetaData in org.jooq.Meta, which you can access via DSLContext.meta(). The objects returned from Meta are again jOOQ's Schema, Table, Field objects, which you can use with the rest of the API.

Using the code generator with a Java-driven database schema

On a side note, Vlad Mihalcea has written this very interseting blog post about how to use the jOOQ code generator in a Hibernate project, where the database is driven by the JPA-annotated Java model. Maybe that is useful to you as well.



来源:https://stackoverflow.com/questions/27083958/can-jooq-be-used-without-code-generation

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