Class LongRowMapper

java.lang.Object
com.randomnoun.common.spring.LongRowMapper
All Implemented Interfaces:
org.springframework.jdbc.core.RowMapper<Long>

public class LongRowMapper extends Object implements org.springframework.jdbc.core.RowMapper<Long>
This class is intended to replace the standard RowMapper provided by Spring to return a List of Long objects (rather than a List of Maps). The queries executed by this rowMapper must therefore always evaluate to a single numeric column

This class can be used as in the following code fragment:

                List longList = jt.query(
                    "SELECT DISTINCT lngId FROM tblCave " +
                    "WHERE txtSecretPassword = ? ",
                    new Object[] { "open sesame" },
                    new RowMapperResultReader(new LongRowMapper() ));
 
Author:
knoxg
  • Constructor Details

    • LongRowMapper

      public LongRowMapper()
      Creates a new ClobRowMapper object.
  • Method Details

    • mapRow

      public Long mapRow(ResultSet resultSet, int rowNumber) throws SQLException
      Returns a single Long representing this row.
      Specified by:
      mapRow in interface org.springframework.jdbc.core.RowMapper<Long>
      Parameters:
      resultSet - The resultset to map
      rowNumber - The current row number
      Returns:
      a single object representing this row.
      Throws:
      org.springframework.dao.TypeMismatchDataAccessException - if the first column of the resultset is not numeric.
      SQLException