[英]How do I programatically get the jOOQ Table of a Hibernate model?
I am using Hibernate + jOOQ + PostgreSQL. 我正在使用Hibernate + jOOQ + PostgreSQL。
I have a Hibernate model as follows: 我有一个Hibernate模型如下:
import javax.persistence.*;
@Entity
@Table(name="user")
public class User {
public UUID id;
public String email;
public Date createdAt;
}
I would like to programatically get the jOOQ Table object for this model. 我想以编程方式获取此模型的jOOQ Table对象。
I've done this by getting all the tables from jooq.meta().getTables()
and then filtering through those.. But that's inefficient and cumbersome. 我通过从
jooq.meta().getTables()
获取所有表来完成此操作,然后通过这些表进行过滤。但这样做效率低且繁琐。
How do I go about doing this? 我该怎么做呢?
The jOOQ code generator has a JPADatabase
that you can configure as a meta data source. jOOQ代码生成器有一个
JPADatabase
,您可以将其配置为元数据源。 It will then use Hibernate behind the scenes to publish your entities into an in-memory H2 database, and reverse engineer that again using standard code generation functionality. 然后,它将在后台使用Hibernate将您的实体发布到内存中的H2数据库中,并使用标准代码生成功能再次对其进行反向工程。 This way, you can keep your entities and your jOOQ code in sync
这样,您可以保持实体和jOOQ代码同步
More details here: https://www.jooq.org/doc/latest/manual/code-generation/codegen-jpa 更多细节: https : //www.jooq.org/doc/latest/manual/code-generation/codegen-jpa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.