SQLDataType
Converter for data types.
A general data type conversion interface that can be provided to jOOQ at
various places in order to perform custom data type conversion. Conversion is
directed, this means that the Converter is used
fromType() is the type as defined in the database. Think of
"FROM" = "reading".toType() is the user-defined
type
Note: In order to avoid unwanted side-effects, it is highly recommended (yet
not required) for from(Object) and to(Object) to be
reciprocal. The two methods are reciprocal, if for all
X and Y, it can be said that
Y.equals(converter.from(X)), then
X.equals(converter.to(Y)).X.equals(converter.from(converter.to(X)))X.equals(converter.to(converter.from(X)))Furthermore, it is recommended (yet not required) that
converter.from(null) == nullconverter.to(null) == null
Irrespective of the Converter's encoding of null
values above, an implementation must be able to handle null
values.
DataTypes
jOOQ provides built in data types through SQLDataType. Users can
define their own data types programmatically by calling
DataType#asConvertedDataType(Converter) or
DataType#asConvertedDataType(Binding), for example. Custom data types
can also be defined on generated code using the
<forcedType/> configuration, see the
manual for more details
| Modifier and Type | Method and Description |
|---|---|
| public default <X> @NotNull Converter | |
| public default @NotNull Converter | |
| public U | Returns: The user object.The database object. databaseObject)Read and convert a database object to a user object. |
| public static < the database type T, the user type U> @NotNull Converter | |
| public static < the database type. T, the user type. U> @NotNull Converter | Returns: The converter.The database type. fromType, Class<U> The user type. toType, Function<? super T, ? extends U> A function converting from T to U when reading from the
database. from)Construct a new read-only converter from a function. |
| public @NotNull Class | |
| public default @NotNull Converter | |
| public static < the database type. T, the user type. U> @NotNull Converter | Returns: The converter.The database type. fromType, Class<U> The user type. toType, Function<? super T, ? extends U> A function converting from T to U when reading from the
database. from, Function<? super U, ? extends T> A function converting from U to T when writing to the database. to)Construct a new converter from functions. |
| public static < the database type T, the user type U> @NotNull Converter | Returns: The converter.The database type fromType, Class<U> The user type toType, Function<? super T, ? extends U> A function converting from T to U when reading from the
database. from, Function<? super U, ? extends T> A function converting from U to T when writing to the database. to)Construct a new converter from functions. |
| public T | Returns: The database object.The user object. userObject)Convert and write a user object to a database object. |
| public static < the database type T, the user type U> @NotNull Converter | |
| public static < the database type T, the user type U> @NotNull Converter | Returns: The converter.The database type fromType, Class<U> The user type toType, Function<? super U, ? extends T> A function converting from U to T when writing to the database. to)Construct a new write-only converter from a function. |
| public @NotNull Class |
| andThen | back to summary |
|---|---|
| public default <X> @NotNull Converter Chain a converter to this converter.
| |
| forArrays | back to summary |
|---|---|
| public default @NotNull Converter Turn this converter into a converter for arrays.
| |
| from | back to summary |
|---|---|
| public U from(T databaseObject) Read and convert a database object to a user object.
| |
| from | back to summary |
|---|---|
| public static <T, U> @NotNull Converter Construct a new read-only converter from a function. | |
| fromNullable | back to summary |
|---|---|
| public static <T, U> @NotNull Converter Construct a new read-only converter from a function.
This works like Example:
| |
| fromType | back to summary |
|---|---|
| public @NotNull Class The database type.
| |
| inverse | back to summary |
|---|---|
| public default @NotNull Converter Inverse this converter.
| |
| of | back to summary |
|---|---|
| public static <T, U> @NotNull Converter Construct a new converter from functions.
| |
| ofNullable | back to summary |
|---|---|
| public static <T, U> @NotNull Converter Construct a new converter from functions.
This works like Example:
| |
| to | back to summary |
|---|---|
| public T to(U userObject) Convert and write a user object to a database object.
| |
| to | back to summary |
|---|---|
| public static <T, U> @NotNull Converter Construct a new write-only converter from a function. | |
| toNullable | back to summary |
|---|---|
| public static <T, U> @NotNull Converter Construct a new write-only converter from a function.
This works like Example:
| |
| toType | back to summary |
|---|---|
| public @NotNull Class The user type.
| |