user8439161
user8439161

Reputation:

jOOQ code generation for multiple databases with different schemas

For my project I want to use jOOQ, but I have 3 databases. Two of them are similar (staging, production) and the third is the database for the application, with a completely different schema.The database Version is the same for all of them, MySQl 5.6. The difference is between the used tables, in one database i got the company translations and in the other database some customers etc.. Plain SQL is very unreadable, because the queries are very complicated. I know this makes no sense, but this is what I got.

Is there a possible way to do the code generation for different databases with different schemas?

I use Maven for the code generation.

Upvotes: 3

Views: 4372

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 220762

The way you go about multiple executions of the jOOQ code generator plugin with Maven is the same as with any Maven plugin. By specifying multiple executions:

<plugin>
    <groupId>org.jooq.trial</groupId>
    <artifactId>jooq-codegen-maven</artifactId>
    <version>3.11.4</version>
    <executions>
        <execution>
            <id>exec-1</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>...</configuration>
        </execution>
        <execution>
            <id>exec-2</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>...</configuration>
        </execution>
    </executions>
</plugin>

The individual executions are completely independent, and they each have their own configurations.

Upvotes: 7

Related Questions