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


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

The code generator supports a set of annotations on generated code, which can be turned on using the following flags. These annotations include:

  • Generated annotations: The JDK generated annotation can be added to all generated classes to include some useful meta information, like the jOOQ version, or the schema version, or the generation date. Depending on the configured generatedAnnotationType, the annotation is one of:
  • Nullable annotations: When using alternative JVM languages like Kotlin, it may be desireable to have some hints related to nullability on generated code. When jOOQ encounters a nullable column, for instance, a JSR-305 @Nullable annotation could warn Kotlin users about well-known nullable columns. @Nonnull columns are more treacherous, as there are numerous reasons why a jOOQ Record could contain a null value in such a column, e.g. when the record was initialised without any values, or when the record originates from a UNION or OUTER JOIN.

    The nullableAnnotationType and nonnullAnnotationType configurations allow for specifying an alternative, qualified annotation name other than the JSR-305 types below.
  • JPA annotations: A minimal set of JPA annotations can be generated on POJOs and other artefacts to convey type and metadata information that is available to the code generator. These annotations include: While jOOQ generated code cannot really be used as full-fledged entities (use e.g. Hibernate or EclipseLink to generate such entities), this meta information can still be useful as documentation on your generated code. Some of the annotations (e.g. @Column) can be used by the org.jooq.impl.DefaultRecordMapper for mapping records to POJOs.
  • Validation annotations: A set of Bean Validation API annotations can be added to the generated code to convey type information. They include: jOOQ does not implement the validation spec, nor does it validate your data, but you can use third-party tools to read the jOOQ-generated validation annotations.
  • Spring annotations: Some useful Spring annotations can be generated on DAOs for better Spring integration. These include:
    • org.springframework.beans.factory.annotation.Autowired
    • org.springframework.stereotype.Repository

The flags governing the generation of these annotations are:

XML (standalone and maven)
<configuration xmlns="">
      <!-- Possible values for generatedAnnotationType
         - DETECT_FROM_JDK
new org.jooq.meta.jaxb.Configuration()
    new Generate()

      // Possible values for generatedAnnotationType
      // - DETECT_FROM_JDK
myConfigurationName(sourceSets.main) {
  generator {
    generate {

      // Possible values for generatedAnnotationType
      // - DETECT_FROM_JDK
      generatedAnnotation = true
      generatedAnnotationType = 'DETECT_FROM_JDK'
      generatedAnnotationDate = true
      nullableAnnotation = true
      nullableAnnotationType = 'javax.annotation.Nullable'
      nonnullAnnotation = true
      nonnullAnnotationType = 'javax.annotation.Nonnull'
      jpaAnnotations = true
      jpaVersion = 2.2
      validationAnnotations = true
      springAnnotations = true


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

The jOOQ Logo