Interface Column.Converter<T,C>

Type Parameters:
T - the type of the value
C - the type of the underlying column
Enclosing interface:
Column<T>

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 Type
    Method
    Description
    fromColumnValue(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

      C toColumnValue(T value, Statement statement) throws SQLException
      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 unless handlesNull() is overridden
      statement - 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

      T fromColumnValue(C columnValue) throws SQLException
      Translates the given sql column value into a column value.
      Parameters:
      columnValue - the sql value to translate from, not null unless handlesNull() is overridden
      Returns:
      the value of sql columnValue
      Throws:
      SQLException - in case of an exception