3

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.

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142

1 Answers1

7

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.

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • Thank you, i am not so familiar with Maven, but this is exactly what i need! –  Sep 19 '18 at 08:20
  • @M.Soldin: Learning by doing! – Lukas Eder Sep 19 '18 at 10:36
  • This is not working when moving the part inside the tag, how this is working your side ? – sahlouls Apr 06 '20 at 09:24
  • 1
    @sahlouls It depends on how you execute Maven. There are some known limitations, which manifest specifically when invoking executions from IntelliJ. Unrelated to jOOQ: https://stackoverflow.com/q/27804862/521799, https://stackoverflow.com/q/2192660/521799, etc... – Lukas Eder Apr 06 '20 at 10:20
  • @LukasEder thanks for pointing that, the issue was related to IntelliJ and not maven itself. I managed to create dedicated IntelliJ lauchers : jooq-codegen:generate@generate-exec-1 -f pom.xml jooq-codegen:generate@generate-exec-2 -f pom.xml – sahlouls Apr 06 '20 at 11:13