Module is.codion.framework.domain
Interface Column.Converter<T,C>
- Type Parameters:
T
- the type of the valueC
- the type of the underlying column
public static interface Column.Converter<T,C>
Converts to and from SQL values, such as integers being used to represent booleans in a database.
By default a Column.Converter
is not expected to handle null values, with null values automatically converted to/from null column values.
If a Column.Converter
needs to handle null values as well as non-null values handlesNull()
must be overridden to return true.
-
Method Summary
Modifier and TypeMethodDescriptionfromColumnValue
(C columnValue) Translates the given sql column value into a column value.default boolean
Unless a Converter handles null, null values are automatically converted to null column values.toColumnValue
(T value, Statement statement) Translates the given value into a sql value, usually this is not required but for certain types this may be necessary, such as boolean values where the values are represented by a non-boolean data type in the underlying database
-
Method Details
-
handlesNull
default boolean handlesNull()Unless a Converter handles null, null values are automatically converted to null column values.- Returns:
- true if this Converter handles the null value, default false
-
toColumnValue
Translates the given value into a sql value, usually this is not required but for certain types this may be necessary, such as boolean values where the values are represented by a non-boolean data type in the underlying database- Parameters:
value
- the value to translate, not null unlesshandlesNull()
is overriddenstatement
- the statement using the value, may be null- Returns:
- the sql value used to represent the given value
- Throws:
SQLException
- in case of an exception
-
fromColumnValue
Translates the given sql column value into a column value.- Parameters:
columnValue
- the sql value to translate from, not null unlesshandlesNull()
is overridden- Returns:
- the value of sql
columnValue
- Throws:
SQLException
- in case of an exception
-