Search code examples
javaoraclemavenjooqjooq-codegen-maven

How do I make JOOQ codegen work with Oracle Edition-Based Redefinition?


I'm working on a project with an Oracle database where we have decided to enable Edition based redefinition. We're also using jooq-codegen for creating Java objects based on objects we have created in the database.

I have read through the documentation for jooq-codegen, but have issues finding a way to make JOOQ work with Oracle editions. Normally I would use an alter session set edition=<some edition> statement to connect to the correct edition, but I can't find a way to do this with jooq-codegen.

Is there any way to do init queries with jooq-codegen, or maybe even a way to specify an edition with jooq-codegen? I'm hoping there is something I have overlooked as I can't find this in the documentation.

I don't think it should matter, but I'm using maven and this will be ran in Jenkins.


Solution

  • That's an interesting case where it might be beneficial to be able to run additional SQL statements after a JDBC connection has been initialised by the code generator. Probably worth a feature request you could report here.

    As a workaround, you can always:

    • Extend the OracleDatabase from the jOOQ-meta module and override the create0() method, which provides an initialised DSLContext for all of your code generation meta queries.
    • Use a programmatic code generation configuration and initialise the JDBC connection yourself before passing it to the code generator