New versions: Dev (3.14)

Synthetic identities

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

jOOQ's code generator recognises identity columns if they are reported as such by the database. Some databases do not support "real" identity columns, but allow for emulating them, e.g. through triggers and sequences (e.g. Oracle prior to 12c). If a column is a known "identity" without formally being one, users can specify regular expressions that match all tables and columns, which will be treated as if they were formal identities. For example:

XML (standalone and maven)
Programmatic
Gradle
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.13.0.xsd">
  <generator>
    <database>
      <syntheticObjects>
        <identities>
          <identity>
          
            <!-- Optional regular expression matching all tables that have this identity. -->
            <tables>SCHEMA\.TABLE</tables>
            
            <!-- List all columns that are identities -->
            <fields>ID</fields>
          </identity>
        </identities>
      </syntheticObjects>
    </database>
  </generator>
</configuration>
new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withDatabase(new Database()
      .withSyntheticObjects(new SyntheticObjectsType()
        .withIdentities(
          new SyntheticIdentityType()

            // Optional regular expression matching all tables that have this identity.
            .withTables("SCHEMA\\.TABLE")

            // List all columns that are identities
            .withFields("ID")
        )
      )
    )
  )
myConfigurationName(sourceSets.main) {
  generator {
    database {
      syntheticObjects {
        identities {
          identity {

            // Optional regular expression matching all tables that have this identity.
            tables = 'SCHEMA\\.TABLE'

            // List all columns that are identities
            fields = 'ID'
          }
        }
      }
    }
  }
}

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

The jOOQ Logo