New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9

Generator

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

This mandatory top level configuration element wraps all the remaining configuration elements related to code generation, including the overridable code generator class.

XML (standalone and maven)
Programmatic
Gradle
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.9.2.xsd">
  <generator>
  
    <!-- Optional: The fully qualified class name of the code generator. -->
    <name>...</name>
    
    <!-- Optional: The programmatic or configurative generator strategy. -->
    <strategy/>
    
    <!-- Optional: The jooq-meta configuration, configuring the information schema source. -->
    <database/>
    
    <!-- Optional: The jooq-codegen configuration, configuring the generated output content. -->
    <generate/>
    
    <!-- Optional: The generation output target --> 
    <target/>
  </generator>
</configuration>
new org.jooq.util.jaxb.Configuration()
  .withGenerator(new Generator()

    // Optional: The fully qualified class name of the code generator.
    .withName(...)

    // Optional: The programmatic or configurative generator strategy.
    .withStrategy()

    // Optional: The jooq-meta configuration, configuring the information schema source.
    .withDatabase()

    // Optional: The jooq-codegen configuration, configuring the generated output content.
    .withGenerate()

    // Optional: The generation output target
    .withTarget()
  )
myConfigurationName(sourceSets.main) {
  generator {

    // Optional: The fully qualified class name of the code generator.
    name = ...

    // Optional: The programmatic or configurative generator strategy.
    strategy {}

    // Optional: The jooq-meta configuration, configuring the information schema source.
    database {}

    // Optional: The jooq-codegen configuration, configuring the generated output content.
    generate {}

    // Optional: The generation output target
    target {}
  }
}

As always, when regular expressions are used, they are regular expressions with default flags.

Specifying your own generator

The <name/> element allows for specifying a user-defined generator implementation. This is mostly useful when generating custom code sections, which can be added programmatically using the code generator's internal API. For more details, please refer to the relevant section of the manual.

Specifying a strategy

jOOQ by default applies standard Java naming schemes: PascalCase for classes, camelCase for members, methods, variables, parameters, UPPER_CASE_WITH_UNDERSCORES for constants and other literals. This may not be the desired default for your database, e.g. when you strongly rely on case-sensitive naming and if you wish to be able to search for names both in your Java code and in your database code (scripts, views, stored procedures) uniformly. For that purpose, you can override the <strategy/> element with your own implementation, either:

For more details, please refer to the relevant sections, above.

jooq-meta and jooq-codegen configuration

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo