
jOOQ Masterclass
By :

Another utility of <forcedTypes/>
is data type rewrites. This allows us to explicitly choose the SQL data type (supported by the database, or unsupported but present in org.jooq.impl.SQLDataType
) that should be used in Java.
For instance, in Oracle, a common use case is to map the missing BOOLEAN
type as NUMBER(1,0)
or CHAR(1)
, as follows:
CREATE TABLE sale ( ... hot NUMBER(1,0) DEFAULT 0 hot CHAR(1) DEFAULT '1' CHECK (hot IN('1', '0')) ... }
But this means that the jOOQ Code Generator will map fields of type NUMBER(1, 0)
to the SQLDataType.TINYINT
SQL data type and the java.lang.Byte
type and, respectively, the fields of type CHAR(1)
to the SQLDataType.CHAR
SQL data type and the String
Java type.
But the Java String
type is commonly associated with text data manipulation, while the Byte
type is commonly associated with binary data manipulations (for example, reading...