Interface RowMapper<T>

Type Parameters:
T - the mapped type.
All Known Subinterfaces:
RowViewMapper<T>
All Known Implementing Classes:
BeanMapper, ConstructorMapper, FieldMapper, JoinRowMapper, JpaMapper, MapEntryMapper, MapMapper, org.jdbi.v3.core.mapper.reflect.internal.PojoMapper, SingleColumnMapper
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RowMapper<T>
Maps result set rows to objects.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    init(ConfigRegistry registry)
    Allows for initialization of the row mapper instance within a ConfigRegistry scope.
    Map the current row of the result set.
    default RowMapper<T>
    Returns a specialized row mapper, optimized for the given result set.
  • Method Details

    • map

      T map(ResultSet rs, StatementContext ctx) throws SQLException
      Map the current row of the result set. This method should not cause the result set to advance; allow Jdbi to do that, please.
      Parameters:
      rs - the result set being iterated
      ctx - the statement context
      Returns:
      the value to produce for this row
      Throws:
      SQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle it
    • specialize

      default RowMapper<T> specialize(ResultSet rs, StatementContext ctx) throws SQLException
      Returns a specialized row mapper, optimized for the given result set.

      Before mapping the result set from a SQL statement; Jdbi will first call this method to obtain a specialized instance. The returned mapper will then be used to map the result set rows, and discarded.

      Implementing this method is optional; the default implementation returns this. Implementors might choose to override this method to improve performance, e.g. by matching up column names to properties once for the entire result set, rather than repeating the process for every row.

      Parameters:
      rs - the result set to specialize over
      ctx - the statement context to specialize over
      Returns:
      a row mapper equivalent to this one, possibly specialized.
      Throws:
      SQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle it
      See Also:
    • init

      default void init(ConfigRegistry registry)
      Allows for initialization of the row mapper instance within a ConfigRegistry scope. This method is called once when the row mapper is first used from a ConfigRegistry.

      Note that handles, statements, sql objects etc. all create copies of the registry, and this method will be called for every copy

      Parameters:
      registry - A reference to the ConfigRegistry that this instance belongs to.