简体   繁体   English

我如何以编程方式获取Hibernate模型的jOOQ表?

[英]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.

相关问题 如何使用 jOOQ fetchInto() 将 map 转换为现有的 Hibernate model? - How to map to an existing Hibernate model using jOOQ fetchInto()? 如何用jooq“选择一些东西(...)”? - How do I do “SELECT something IN (…)” with jooq? 如何在不将所有表元数据拉入内存的情况下使用 jOOQ 获取特定表的列? - How can I get columns for a specific table using jOOQ without pulling all table metadata into memory? 如何从数据库表中获取数据并将数据更新到休眠中的另一个表中? 我已经在JSP中完成了,但是我想在Hibernate中完成 - How to get data from database table and update that data into another table in hibernate? I have done it in JSP but i want to do in Hibernate 我如何在 jOOQ 中写一个“像‘somevalue%’? - How do I write a "like 'somevalue%' in jOOQ? 如何使用 jOOQ 将 long 转换为 LocalDateTime - How do I convert a long to a LocalDateTime with jOOQ Hibernate:如何将表与自身连接? - Hibernate: How do I join a table with itself? 使用将数据加载到CSV文件加载到mysql表中。 如何将以下查询转换为JOOQ? - Load CSV file to a mysql table using Load data into. How do I convert the following query into JOOQ? 如何以编程方式将 OSGi 包状态作为字符串获取? - How do I get OSGi bundle state programatically as String? 如何以编程方式获取堆栈内存统计信息? - How do I get stack memory stats programatically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM