Package st.orm

Interface Converter<D,E>

Type Parameters:
D - the database-visible type (JDBC-compatible).
E - the entity value type.

public interface Converter<D,E>
Converts between an entity value type and a database column type.

A converter maps a component value of type E to a JDBC-compatible value of type D, and back again. Converters are used when a record component is not directly supported by the SQL driver or when a custom mapping is desired.

Conversion is applied in one of the following ways:

  • Explicit conversion A converter can be selected directly through @Convert.
  • Auto-apply A converter can be automatically applied by marking the class with DefaultConverter. Default converters are used only when no explicit converter is present.
  • No conversion If a component has neither an explicit converter nor an applicable auto-apply converter, Storm uses the built-in mapping.

Implementations must provide a public no-argument constructor so Storm can instantiate them during classpath scanning.

Since:
1.7
  • Method Summary

    Modifier and Type
    Method
    Description
    fromDatabase(D dbValue)
    Converts a database column value to an entity value.
    toDatabase(E value)
    Converts an entity value to a database column value.
  • Method Details

    • toDatabase

      D toDatabase(@Nullable E value)
      Converts an entity value to a database column value.
      Parameters:
      value - the entity value, possibly null.
      Returns:
      the database-compatible value, possibly null.
    • fromDatabase

      E fromDatabase(@Nullable D dbValue)
      Converts a database column value to an entity value.
      Parameters:
      dbValue - the column value read from the database, possibly null.
      Returns:
      the converted entity value, possibly null.