Interface RowMapper<T>

  • Type Parameters:
    T - the type of object produced by this mapper

    public interface RowMapper<T>
    A closure that maps a row in a ResultSet to an instance of a given type.

    Example:

     
     RowMapper<Person> personMapper = new RowMapper<>() {
       public Person mapRow(ResultSet rs, int rowNum) throws SQLException {
         Person person = new Person();
         person.setId(rs.getLong("id"));
         person.setName(rs.getName("name"));
         person.setAge(rs.getInt("age"));
         return person;
       }
     };
     
    Author:
    Carl Harris
    • Method Detail

      • mapRow

        T mapRow​(ResultSet rs,
                 int rowNum)
          throws SQLException
        Maps a single row in a ResultSet to a new instance of the receiver's declared data type.
        Parameters:
        rs - result set positioned to the row that is to be mapped
        rowNum - current row number (the first row is row 1)
        Returns:
        instance of type T
        Throws:
        SQLException