Available in versions: Dev (3.19) | Latest (3.18) | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
Auto data type conversion
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Many native SQL data types can be automatically converted from one another, such as
INTEGER and vice versa.
The jOOQ API also supports a variety of such auto conversions through the
org.jooq.tools.Convert utility API, which implements the following rules:
nullis always converted to
null, or the primitive default value, or
Optional.empty(), regardless of the target type.
- Identity conversion (converting a value to its own type) is always possible.
- Primitive types can be converted to their wrapper types and vice versa
- All types can be converted to String
- All types can be converted to Object
- All Number types can be converted to other Number types
Stringtypes can be converte to
Boolean. Possible (case-insensitive) values for
Possible (case-insensitive) values for
All other values evaluate to
java.sql.Timestamp), as well as most
java.time.OffsetDateTime, as well as
java.time.Instant) can be converted into each other.
bytecan be converted into
String, using the platform's default charset
Objectcan be converted into any other array type, if array elements can be converted, too
This auto conversion can be applied explicitly, but is also available through a variety of API, in particular anywhere a
java.lang.Class reference can be provided, such as:
Record record = ... int i = record.get(0, int.class); String s = record.get(1, String.class);
Do you have any feedback about this page? We'd love to hear it!