I use the liquibase and jooq and i need to generate my pojo's directly from liquibase xml files, but i have a problem to override the default "H2" dialect with Postgres. Actually, i've tried to setup dialect via property within plugin "configuration" section but it still uses H2. Can someone ask me please how can i make jooq use postgres dialect when reading xml files and generating java classes.
Here is the used libraries versions
<properties>
<jooq.version>3.13.4</jooq.version>
<vertx-jooq.version>5.1.1</vertx-jooq.version>
<postgres.version>42.2.12</postgres.version>
</properties>
Here is the my plugin configuration
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<id>jooq-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.version}</version>
</dependency>
<dependency>
<groupId>io.github.jklingsporn</groupId>
<artifactId>vertx-jooq-generate</artifactId>
<version>${vertx-jooq.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<configuration>
<generator>
<name>io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator</name>
<database>
<name>org.jooq.meta.extensions.liquibase.LiquibaseDatabase</name>
<properties>
<property>
<key>scripts</key>
<value>src/main/resources/liquibase/tenant/changelog.xml</value>
</property>
<property>
<key>changeLogParameters.contexts</key>
<value>!test</value>
</property>
<-- unfortunately this property doesn't work -->
<property>
<key>dialect</key>
<value>POSTGRES</value>
</property>
</properties>
<outputSchemaToDefault>true</outputSchemaToDefault>
<unsignedTypes>false</unsignedTypes>
<forcedTypes />
</database>
<generate>
<daos>true</daos>
<fluentSetters>true</fluentSetters>
</generate>
<target>
<packageName>org.folio.rest.jooq</packageName>
</target>
<strategy>
<name>io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy</name>
</strategy>
</generator>
</configuration>
</plugin>
As of jOOQ 3.14, the org.jooq.meta.extensions.liquibase.LiquibaseDatabase
data source for the jOOQ code generator uses H2 behind the scenes to simulate a migration, instead of actually running the migration on your target database. This allows for working with jOOQ and your liquibase migration scripts without an actual database instance and connection. In the future, it might be possible to spin up a PostgreSQL instance, transparently, using testcontainers: https://github.com/jOOQ/jOOQ/issues/6551
Here's an example how to set it up: https://github.com/jOOQ/jOOQ/tree/main/jOOQ-examples/jOOQ-testcontainers-example (not too hard)
If you wish to work with an actual PostgreSQL database, just run the liquibase migration using the liquibase maven plugins before you run the jOOQ code generation, having both connect to the same database server.