Available in versions: 3.13 | 3.12 | 3.11 | 3.10 | 3.9

Override primary keys

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

In some legacy contexts, there might not be any primary key, only a bunch of unique keys, defined in a table. jOOQ cannot pick one of those as the "primary key", and the table won't be generated as a org.jooq.UpdatableRecord. Users can, however, use this regular expression to match all UNIQUE key names that should be used as a table's primary key.

XML (standalone and maven)

See the configuration XSD, standalone code generation, and maven code generation for more details.

new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withDatabase(new Database()

See the configuration XSD andprogrammatic code generation for more details.

generationTool {
  generator {
    database {
      overridePrimaryKeys = 'MY_UNIQUE_KEY_NAME'

See the configuration XSD and gradle code generation for more details.

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

If several keys match, a warning is emitted and the first one encountered will be used. This flag will also replace synthetic primary keys, if it matches.


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

The jOOQ Logo