-
- Type Parameters:
T
- target mapping type
- All Known Implementing Classes:
JsonProcessingMapper
public interface DbMapper<T>
A mapper to map database objects to/from a specific type.Mappers can be either provided through
DbClientProvider
or registered directly with theDbClientProviderBuilder.addMapper(DbMapper, Class)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
read(DbRow row)
Read database row and convert it to target type instance.List<?>
toIndexedParameters(T value)
Convert target type instance to a statement indexed parameters list.Map<String,?>
toNamedParameters(T value)
Convert target type instance to a statement named parameters map.
-
-
-
Method Detail
-
read
T read(DbRow row)
Read database row and convert it to target type instance.- Parameters:
row
- source database row- Returns:
- target type instance containing database row
-
toNamedParameters
Map<String,?> toNamedParameters(T value)
Convert target type instance to a statement named parameters map.- Parameters:
value
- mapping type instance containing values to be set into statement- Returns:
- map of statement named parameters mapped to values to be set
- See Also:
DbStatement.namedParam(Object)
-
toIndexedParameters
List<?> toIndexedParameters(T value)
Convert target type instance to a statement indexed parameters list.Using indexed parameters with typed values is probably not going to work nicely, unless the order is specified and the number of parameters is always related the provided value. There are cases where this is useful though - e.g. for types that represent an iterable collection.
- Parameters:
value
- mapping type instance containing values to be set into statement- Returns:
- map of statement named parameters mapped to values to be set
- See Also:
DbStatement.indexedParam(Object)
-
-