Closed javiercj93 closed 1 month ago
Thanks for your message. Could you please provide the complete INFO
log output
Thanks for your reply!
[INFO] No <inputCatalog/> was provided. Generating ALL available catalogs instead.
[INFO] No <inputSchema/> was provided. Generating ALL available schemata instead.
Sep 19, 2024 4:02:00 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 5.6.15.Final
[INFO] Entities added : Number of entities added: 1
Sep 19, 2024 4:02:01 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
Sep 19, 2024 4:02:01 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Sep 19, 2024 4:02:01 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000227: Running hbm2ddl schema export
Sep 19, 2024 4:02:01 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [name: AttributeConverterExtractor]
Sep 19, 2024 4:02:01 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Sep 19, 2024 4:02:02 PM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService
INFO: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[INFO] License parameters
[INFO] ----------------------------------------------------------
[INFO] Thank you for using jOOQ and jOOQ's code generator
[INFO]
[INFO] Database parameters
[INFO] ----------------------------------------------------------
[INFO] dialect : H2
[INFO] URL :
[INFO] target dir : /Users/javer/jooq-demo/application/src/main/java
[INFO] target package : org.jooq.example.jpa.jooq
[INFO] includes : [.*]
[INFO] excludes : []
[INFO] includeExcludeColumns : false
[INFO] ----------------------------------------------------------
[INFO]
[INFO] JavaGenerator parameters
[INFO] ----------------------------------------------------------
[INFO] annotations
[INFO] generated : false
[INFO] JPA : false
[INFO] JPA version :
[INFO] validation : false
[INFO] spring : false
[INFO] comments
[INFO] comments : true
[INFO] on attributes : true
[INFO] on catalogs : true
[INFO] on columns : true
[INFO] on embeddables : true
[INFO] on keys : true
[INFO] on links : true
[INFO] on packages : true
[INFO] on parameters : true
[INFO] on queues : true
[INFO] on routines : true
[INFO] on schemas : true
[INFO] on sequences : true
[INFO] on tables : true
[INFO] on udts : true
[INFO] sources
[INFO] sources : true
[INFO] sources on views : true
[INFO] global references
[INFO] global references : true
[INFO] catalogs : true
[INFO] domains : true
[INFO] indexes : true
[INFO] keys : true
[INFO] links : true
[INFO] queues : true
[INFO] routines : true
[INFO] schemas : true
[INFO] sequences : true
[INFO] tables : true
[INFO] udts : true
[INFO] object types
[INFO] daos : false
[INFO] indexes : true
[INFO] instance fields : true
[INFO] interfaces : false
[INFO] interfaces (immutable) : false
[INFO] javadoc : true
[INFO] keys : true
[INFO] links : true
[INFO] pojos : false
[INFO] pojos (immutable) : false
[INFO] queues : true
[INFO] records : true
[INFO] routines : true
[INFO] sequences : true
[INFO] sequenceFlags : true
[INFO] table-valued functions : true
[INFO] tables : true
[INFO] udts : true
[INFO] relations : true
[INFO] other
[INFO] deprecated code : true
[INFO] ----------------------------------------------------------
[INFO]
[INFO] Generation remarks
[INFO] ----------------------------------------------------------
[INFO]
[INFO] ----------------------------------------------------------
[INFO] Generating catalogs : Total: 1
[INFO] Version : Database version is supported by dialect H2: 2.2.224 (2023-09-17)
[INFO] ARRAYs fetched : 0 (0 included, 0 excluded)
[INFO] Domains fetched : 0 (0 included, 0 excluded)
[INFO] Tables fetched : 0 (0 included, 0 excluded)
[INFO] Embeddables fetched : 0 (0 included, 0 excluded)
[INFO] Enums fetched : 0 (0 included, 0 excluded)
[INFO] Packages fetched : 0 (0 included, 0 excluded)
[INFO] Routines fetched : 0 (0 included, 0 excluded)
[INFO] Sequences fetched : 0 (0 included, 0 excluded)
[INFO] UDTs fetched : 0 (0 included, 0 excluded)
[INFO] Excluding empty catalog :
[INFO] Affected files: 0
[INFO] Modified files: 0
[INFO] No modified files : This code generation run has not produced any file modifications.
This means, the schema has not changed, and no other parameters (jOOQ version, driver version, database version,
and any configuration elements) have changed either.
In automated builds, it is recommended to prevent unnecessary code generation runs. This run took: 300.331ms
Possible means to prevent this:
- Use manual code generation and check in generated sources: https://www.jooq.org/doc/latest/manual/code-generation/codegen-version-control/
- Use schema version providers: https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-version-providers/
- Use gradle tasks and inputs: https://docs.gradle.org/current/userguide/incremental_build.html
Ah, I see, you're probably generating stuff into a "public"
schema (due to the org.hibernate.dialect.PostgreSQLDialect
), but we're using H2 behind the scenes to reverse engineer what Hibernate generates, and that will default to the "PUBLIC
" schema instead - could that be it?
I'll try to reproduce it tomorrow, but you could try removing that. It's not really needed.
It did not work either without
<property>
<key>hibernate.dialect</key>
<value>org.hibernate.dialect.PostgreSQLDialect</value>
</property>
I'm afraid I don't see what could be the problem. I cannot reproduce any such issue with our integration tests. Can you provide a more complete reproducer, e.g. based on our template here? https://github.com/jOOQ/jOOQ-mcve
If that's too much effort, some other troubleshooting ideas:
mvnDebug
to step into the JPADatabase
and check if the in-memory H2 database is really populated correctlyThanks for the support @lukaseder, really appreciate it.
I have recreated an example based on the provided templates (I've removed all the other modules and left just an entity module + the "generator" module.
[INFO] Entities added : Number of entities added: 2
Sep 20, 2024 10:37:46 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
Sep 20, 2024 10:37:46 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Sep 20, 2024 10:37:47 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000227: Running hbm2ddl schema export
Sep 20, 2024 10:37:47 AM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [name: AttributeConverterExtractor]
Sep 20, 2024 10:37:47 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Sep 20, 2024 10:37:47 AM org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator initiateService
INFO: HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[INFO] License parameters
This time I added a second entity (EntityB)
Please let me know if you are able to replicate on your side and apologies because it is probably some misconfiguration on my side.
Link to example -> https://github.com/javiercj93/jOOQ-mcve
Thanks for the reproducer. I can see how nothing is generated, will investigate.
Using a debugger, right after the Hibernate export command, I can see that no tables have been added to the in-memory H2 database. Only the INFORMATION_SCHEMA
is present:
OK, I see. There are some exceptions being swallowed by the schema export:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "create table entity_a (id bigint generated by default as identity, description varchar(255), name varchar(255), [*]value integer, primary key (id))"; expected "identifier"; SQL statement:
create table entity_a (id bigint generated by default as identity, description varchar(255), name varchar(255), value integer, primary key (id)) [42001-224]
Very unfortunate... You ran into this issue:
A workaround is to quote your identifier: @Column(name = "`value`")
There are two bugs in jOOQ here:
SchemaExport
The H2 keyword specific bug will be this one:
I'll fix this issue here right away, re-throwing Hibernate's errors when exporting the schema
Fixed in versions:
Thanks again for your report and your patience, providing the MCVE. I should have tried your actual entity from the issue description when reproducing the problem. I used my own entity and focused only on what could have gone wrong with the configuration...
The current fix may lead to this regression:
13:54:34,923 [ERROR] Failed to execute goal org.jooq.trial:jooq-codegen-maven:3.20.0-SNAPSHOT:generate (generate-jpadatabase) on project jooq-test-codegen-java: Error running jOOQ code generation tool: Error while exporting schema: Halting on error : Error executing DDL "drop table if exists master_data.language CASCADE " via JDBC Statement: Schema "MASTER_DATA" not found; SQL statement:
Since we're working on an in-memory database, might as well omit the dropping of the schema
Appreciate your help! Thanks for the explanation and workaround!
Your question
I've tried to follow the documentation here, however, I was unable to make it work and I could not find any working example. What I am trying to achieve is simple, I want to generate jooq code based on jpa entities.
In a multimodule project I've created an entitties module which contains a single entity:
Then in my application module, I've added the following plugin configuration:
When I run it, I can see the following:
But then nothing is generated, could I get a link to an example or something I could use as a reference? The following examples in a similar issue does not seem available anymore:
jOOQ Version
3.19.11
Database product and version
mysql8
Java Version
openjdk v17
JDBC / R2DBC driver name and version (include name if unofficial driver)
No response