jooq-codegen for different DB with different Posgres versions

193 views Asked by At

I have a following jooq-codegen-maven configuration for different DBs:

<plugins>
    <plugin>
        <groupId>org.jooq</groupId>
        <artifactId>jooq-codegen-maven</artifactId>
        <version>${jooq.version}</version>
        <executions>
            <execution>
                <id>generate-1</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <configurationFile>
                        src/main/resources/jooq/jooq-config-1.xml
                    </configurationFile>
                </configuration>
            </execution>
            <execution>
                <id>generate-2</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <configurationFile>
                        src/main/resources/jooq/jooq-config-2.xml
                    </configurationFile>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

jooq-config-1.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.12.0.xsd">
    <jdbc>
        <driver>org.postgresql.Driver</driver>
        <url>jdbc:postgresql://host_pg9_6_11/db</url>
        <user>user</user>
        <password>pass</password>
    </jdbc>
    <generator>
        <database>
            <name>org.jooq.meta.postgres.PostgresDatabase</name>
            <schemata>
                <schema>
                    <inputSchema>billing</inputSchema>
                </schema>
                <schema>
                    <inputSchema>main</inputSchema>
                </schema>
            </schemata>
            <includes>
                (billing.(billing_order|billing_service))|(main.(person|subscription|contact))
            </includes>
        </database>
        <target>
            <packageName>ru.app.postgres.jooq.gen.billing</packageName>
            <directory>target/generated-sources/jooq</directory>
        </target>
    </generator>
</configuration>

jooq-config-2.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd">
    <jdbc>
        <driver>org.postgresql.Driver</driver>
        <url>jdbc:postgresql://host_pg14_5/db</url>
        <user>user</user>
        <password>pass</password>
    </jdbc>
    <generator>
        <database>
            <name>org.jooq.meta.postgres.PostgresDatabase</name>
            <schemata>
                <schema>
                    <inputSchema>main</inputSchema>
                </schema>
            </schemata>
            <includes>
                f_(start|finish)_load_data
            </includes>
        </database>
        <target>
            <packageName>ru.app.postgres.jooq.gen.track</packageName>
            <directory>target/generated-sources/jooq</directory>
        </target>
    </generator>
</configuration>

The issue is that databases has different Postgres version and I get errors 'column pg_proc.prokind does not exist' or 'column pg_proc.proisagg does not exist' depending on the order of the execution sections. If I remove any of execution section codegen works properly.

It looks like generator plugin detects Postgres version only on the first step.

Is there any way to solve this issue?

I use jooq version: 3.12.3, tried 3.14.4 with the same result.

Postgres versions: 9.6.11 for jooq-config-1 and 14.5 for jooq-config-2.

Java 11, Maven 3.8.1

0

There are 0 answers