- 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 TypeMethodDescriptionfromDatabase(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
Converts an entity value to a database column value.- Parameters:
value- the entity value, possiblynull.- Returns:
- the database-compatible value, possibly
null.
-
fromDatabase
Converts a database column value to an entity value.- Parameters:
dbValue- the column value read from the database, possiblynull.- Returns:
- the converted entity value, possibly
null.
-