Interface DbMapperManager


  • public interface DbMapperManager
    Mapper manager of all configured mappers.
    • Field Detail

      • TYPE_NAMED_PARAMS

        static final GenericType<Map<String,​?>> TYPE_NAMED_PARAMS
        Generic type for the Map of String to value pairs for named parameters.
      • TYPE_INDEXED_PARAMS

        static final GenericType<List<?>> TYPE_INDEXED_PARAMS
        Generic type for the List of indexed parameters.
    • Method Detail

      • builder

        static DbMapperManager.Builder builder()
        Create a fluent API builder to configure the mapper manager.
        Returns:
        a new builder instance
      • create

        static DbMapperManager create()
        Create a new mapper manager from Java Service loader only.
        Returns:
        mapper manager
      • read

        <T> T read​(DbRow row,
                   Class<T> expectedType)
            throws MapperException
        Read database row into a typed value.
        Type Parameters:
        T - type of the response
        Parameters:
        row - row from a database
        expectedType - class of the response
        Returns:
        instance with data from the row
        Throws:
        MapperException - in case the mapper was not found
        See Also:
        DbRow.as(Class)
      • toNamedParameters

        <T> Map<String,​?> toNamedParameters​(T value,
                                                  Class<T> valueClass)
        Read object into a map of named parameters.
        Type Parameters:
        T - type of value
        Parameters:
        value - the typed value
        valueClass - type of the value object
        Returns:
        map with the named parameters
        See Also:
        DbStatement.namedParam(Object)
      • toIndexedParameters

        <T> List<?> toIndexedParameters​(T value,
                                        Class<T> valueClass)
        Read object into a list of indexed parameters.
        Type Parameters:
        T - type of value
        Parameters:
        value - the typed value
        valueClass - type of the value object
        Returns:
        list with indexed parameters (in the order expected by statements using this object)
        See Also:
        DbStatement.indexedParam(Object)