简体   繁体   English

可以在没有代码生成的情况下使用JOOQ吗?

[英]Can JOOQ be used without code generation?

I am assessing JOOQ for use in a new system that is still under development. 我正在评估JOOQ用于仍处于开发阶段的新系统。 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). 因此,数据库模式定义应该由Java代码(java中的表定义)驱动。

Is JOOQ appropriate for the above use case? JOOQ适合上述用例吗? Is there a java DSL for schema definition? 是否有用于架构定义的java DSL?

Is JOOQ appropriate for the above use case? JOOQ适合上述用例吗?

Yes, many jOOQ users use only the runtime library without the code generator. 是的,许多jOOQ用户只使用没有代码生成器的运行时库。 Examples can be seen in the getting started guide . 可以在入门指南中看到示例。

Is there a java DSL for schema definition? 是否有用于架构定义的java DSL?

jOOQ wraps JDBC's DatabaseMetaData in org.jooq.Meta , which you can access via DSLContext.meta() . jOOQ包装JDBC的DatabaseMetaDataorg.jooq.Meta ,您可以通过访问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. Meta返回的对象再次是jOOQ的SchemaTableField对象,您可以将其与API的其余部分一起使用。

Using the code generator with a Java-driven database schema 将代码生成器与Java驱动的数据库模式一起使用

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 . 另一方面,Vlad Mihalcea撰写了这篇非常热门的博客文章,介绍如何在Hibernate项目中使用jOOQ代码生成器,其中数据库由JPA注释的Java模型驱动 Maybe that is useful to you as well. 也许这对你也很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM