Interface RowMapper<T>

  • Type Parameters:
    T - The result type
    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>
    Represents an interface used to map rows of a ResultSet.

    Implementations map each row to a generic result and they don't need to worry about handling exceptions: they will be handled by aSQL DataTemplate and passed to a CompletableFuture for further analysis by the user.

    This interface can be used for query methods or for other custom implementations.


    A RowMapper object is reusable. Also, it's a convenient and fast way for implementing a row-mapping logic in a single spot.
    See Also:
    DataTemplate.queryForList(String, RowMapper)
    • Method Detail

      • map

        @Nullable
        T map​(@NotNull
              ResultSet rs,
              int rowNumber)
        throws SQLException
        Implementations will tell how to map EACH row of the ResultSet.
        ResultSet.next() call is not needed: this method should only map values of the current row.
        Parameters:
        rs - the ResultSet, already initialized
        rowNumber - the number of the current row
        Returns:
        a result object for the current row, or null if the result is not available
        Throws:
        SQLException - if the implementation's trying to get column values in the wrong way