Starting with jOOQ 3.16 and #12601, there may be a compilation error with a message like this in your jOOQ generated code:
[ERROR] …/DefaultCatalog.java:[53,73] cannot find symbol
[ERROR] symbol: variable VERSION_3_17
[ERROR] location: class org.jooq.Constants
Typically, this error is mixed with other compilation errors in generated code. Its purpose is to help troubleshoot these other compilation errors. This error is caused by a mismatch between two jOOQ artifacts that are being used by users, including:
org.jooq:jooq(the runtime library)
org.jooq:jooq-codegen(the code generation library)
This is also documented in the Javadoc of said generated code:
/** * A reference to the 3.17 minor release of the code generator. If this * doesn't compile, it's because the runtime library uses an older minor * release, namely: 3.17. You can turn off the generation of this reference * by specifying /configuration/generator/generate/jooqVersionReference */ private static final String REQUIRE_RUNTIME_JOOQ_VERSION = Constants.VERSION_3_17;
Just like with the JDK that has a runtime (the JDK or JRE) and a code generator (the compiler), users must make sure that the runtime version is always >= the code generation version.
If you see the above error, you might have a configuration like this, in your maven or gradle build:
<!-- A runtime dependency. --> <dependency> <groupId>org.jooq</groupId> <artifactId>jooq</artifactId> <version>3.16.9</version> </dependency> <!-- And then, later on: --> <plugin> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <version>3.17.3</version> </plugin>
The 3.17 version of the code generator will produce code that can be consumed only by the runtime library 3.17 or newer. While it is perfectly fine to use an older code generator with a newer runtime:
The above configuration is not supported:
In other words:
- Generated code is forward compatible, but not backward compatible.
- The runtime API (which is used by generated code) is backward compatible, but not forward compatible.
However, if possible, the recommendation is to always match the code generation library and the runtime library to avoid any other trouble.
Turning off the feature
If this code generation feature bothers you, you can always turn it off by specifying:
<configuration> <generator> <generate> <jooqVersionReference>false</jooqVersionReference> </generate> </generator> </configuration>