1

I'm successfully generating jOOQ classes using the jooq-codegen-maven plugin together with the jooq meta hibernate extension.

The names of the generated classes and methods for tables/column are using the actual DB table and column names.

Is possible for the generation to use on the @Entity class simple-name and the @Column instance variables names instead the @Entity(name=TABLE) and @Column(name=COLUMN) ?

To me it will be more intuitive to have the same names as the JPA classes when using jOOQ to create queries.

Thanks

1 Answers1

0

jOOQ doesn't really "know" your entities. Behind the scenes of the JPADatabase, there's a simulation of installing the generated SQL for your entities in an actual database (currently, as of jOOQ 3.15, in H2, but that might change in the future). From then on, jOOQ will continue to connect to an actual database to reverse engineer things, not knowing that this simulated database originates from JPA entities.

As such, it is not possible to "remember" what alternative names you gave to those tables and columns.

However, you might know, and have some naming conventions, which you can encode in a generator strategy.

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • Lukas, thanks for your response. Yes, I understand how it works. I was thinking that codegen would harvest the entities (in the same way Hibernate does create the tables in the DB) creating a reverse mapping from table to bean class name and column to property name. Then the generator strategy could use that do mapping to get the Java identifiers. thx again – Alejandro Abdelnur Aug 26 '21 at 16:32
  • @AlejandrAbdelnur It might be possible to do that... Mind creating a feature request? https://github.com/jOOQ/jOOQ/issues/new/choose – Lukas Eder Aug 26 '21 at 17:11
  • 1
    Lukas, created https://github.com/jOOQ/jOOQ/issues/12368. Thanks – Alejandro Abdelnur Aug 30 '21 at 19:38