Interface DbMapper<T>

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 the DbClientProviderBuilder.addMapper(DbMapper, Class).

  • Method Summary

    Modifier and Type
    Method
    Description
    read(DbRow row)
    Read database row and convert it to target type instance.
    List<?>
    Convert target type instance to a statement indexed parameters list.
    Convert target type instance to a statement named parameters map.
  • Method Details

    • 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:
    • 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: