The jOOQ User Manual. Multiple Pages : Code generation : Advanced generator configuration : Generate : Zero Scale Decimal Types | previous : next |
All versions: 3.11 | Development versions: 3.12
A zero-scale decimal, such as DECIMAL(10)
or NUMBER(10, 0)
is really an integer type with a decimal precision rather than a binary / bitwise precision. Some databases (e.g. Oracle) do not support actual integer types at all, only decimal types. Historically, jOOQ generates the most appropriate integer wrapper type instead of BigDecimal
or BigInteger
:
-
NUMBER(2, 0)
and less: java.lang.Byte -
NUMBER(4, 0)
and less: java.lang.Short -
NUMBER(9, 0)
and less: java.lang.Integer -
NUMBER(19, 0)
and less: java.lang.Long
If this is not a desireable default, it can be deactivated either explicitly on a per-column basis using forced types, or globally using the following flag:
XML configuration (standalone and Maven)
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd"> <generator> <generate> <forceIntegerTypesOnZeroScaleDecimals>true</forceIntegerTypesOnZeroScaleDecimals> </generate> </generator> </configuration>
Programmatic configuration
configuration .withGenerator(new Generator( .withGenerate(new Generate() .withForceIntegerTypesOnZeroScaleDecimals(true))));
Gradle configuration
myConfigurationName(sourceSets.main) { generator { generate { forceIntegerTypesOnZeroScaleDecimals = true } } }