简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM