Interface TypeConverter<T,​A>

  • Type Parameters:
    T - The transitional type.
    A - The application type.

    public interface TypeConverter<T,​A>
    Author:
    Vladimir Alarcon

    Converts back and forth between transitional values and application values.

    The intermediate value is the intermediate Java value read from the database (or written to it) using JDBC.

    The application value is the value the application uses after all transformation from the database.

    For example, a database column DECIMAL(4) can be used to represent a java.lang.Boolean type (that a database does not support natively) using the numeric values zero (0) and one (1). This database column value can be first read through JDBC as a java.lang.Short. Then, it can be converted into a java.lang.Boolean. In this case:

    • DECIMAL(4): the database column type.
    • java.lang.Short: the type of the intermediate value. This value is not available to the application and is briefly used by the persistence layer while reading/writing from/into the database.
    • java.lang.Boolean: the type of the application value. This is the value that the application sees, and is usually stored as a class property of this type.
    • Method Detail

      • decode

        A decode​(T intermediateValue)
      • encode

        T encode​(A applicationValue)