Interface ColumnMapper<T>

Type Parameters:
T - The mapped type
All Known Implementing Classes:
DateTimeMapper, EnumMapper, HStoreColumnMapper
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 ColumnMapper<T>
Maps result set columns to objects.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static <U> ColumnMapper<U>
     
    default void
    init(ConfigRegistry registry)
    Allows for initialization of the column mapper instance within a ConfigRegistry scope.
    map(ResultSet r, int columnNumber, StatementContext ctx)
    Map the given column of the current row of the result set to an Object.
    default T
    map(ResultSet r, String columnLabel, StatementContext ctx)
    Map the given column of the current row of the result set to an Object.
  • Method Details

    • getDefaultColumnMapper

      static <U> ColumnMapper<U> getDefaultColumnMapper()
    • map

      T map(ResultSet r, int columnNumber, StatementContext ctx) throws SQLException
      Map the given column of the current row of the result set to an Object. This method should not cause the result set to advance; allow Jdbi to do that, please.
      Parameters:
      r - the result set being iterated
      columnNumber - the column number to map (starts at 1)
      ctx - the statement context
      Returns:
      the value to return for this column
      Throws:
      SQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle it
    • map

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

      default void init(ConfigRegistry registry)
      Allows for initialization of the column mapper instance within a ConfigRegistry scope. This method is called once when the column 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.