Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 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 (Kotlin)
Gradle (Groovy)
Gradle (third party)
<configuration>
  <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>

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

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)
  )

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

import org.jooq.meta.jaxb.*


configuration {
  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 = GeneratedSerialVersionUID.CONSTANT
    }
  }
}

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

configuration {
  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"
    }
  }
}

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

generationTool {
  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"
    }
  }
}

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

Feedback

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

The jOOQ Logo