New versions: Dev (3.15) | Latest (3.14)

Serial Version UID

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

All jOOQ QueryPart types, including the generated ones, are are serializable. It is thus a good practice to generate a serialVersionUID value in all generated classes, for example:

private static final long serialVersionUID = -2074134614;

By default, this value is 1L to prevent compilation warnings and to minimise noisy diffs should you choose to check in generated sources to version control.

XML (standalone and maven)
Programmatic
Gradle
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd">
  <generator>
    <generate>
      <!-- Possible values for generatedSerialVersionUID
         - CONSTANT (default): Always generate 1L
         - OFF               : Don't generate a serialVersionUID
         - HASH              : Calculate a unique-ish value based on the hash code of the content -->
      <generatedSerialVersionUID>CONSTANT</generatedSerialVersionUID>
    </generate>
  </generator>
</configuration>
new org.jooq.meta.jaxb.Configuration()
  .withGenerator(
    new Generate()

      // Possible values for generatedSerialVersionUID
      // - CONSTANT (default): Always generate 1L
      // - OFF               : Don't generate a serialVersionUID
      // - HASH              : Calculate a unique-ish value based on the hash code of the content
      .withGeneratedSerialVersionUID(GeneratedSerialVersionUID.CONSTANT)
  )
myConfigurationName(sourceSets.main) {
  generator {
    generate {

      // Possible values for generatedSerialVersionUID
      // - CONSTANT (default): Always generate 1L
      // - OFF               : Don't generate a serialVersionUID
      // - HASH              : Calculate a unique-ish value based on the hash code of the content
      generatedSerialVersionUID = 'CONSTANT'
    }
  }
}

Feedback

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

The jOOQ Logo