How do I programatically get the jOOQ Table of a Hibernate model?

RainSear :

I am using Hibernate + jOOQ + PostgreSQL.

I have a Hibernate model as follows:

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.

I've done this by getting all the tables from jooq.meta().getTables() and then filtering through those.. But that's inefficient and cumbersome.

How do I go about doing this?

Lukas Eder :

The jOOQ code generator has a JPADatabase that you can configure as a meta data source. 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. This way, you can keep your entities and your jOOQ code in sync

More details here: https://www.jooq.org/doc/latest/manual/code-generation/codegen-jpa

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=100252&siteId=1