Class StringRowMapper

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

public class StringRowMapper extends Object implements org.springframework.jdbc.core.RowMapper<String>
This class is intended to replace the standard RowMapper provided by Spring to return a List of String objects (rather than a List of Maps). The queries executed by this rowMapper must therefore always evaluate to a single String or CLOB column (the CLOB will be mapped to a String if required).

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

                JdbcTemplate jt = EjbConfig.getEjbConfig().getJdbcTemplate();
                List stringList = jt.query(
                    "SELECT DISTINCT roleName FROM userRole " +
                    "WHERE customerId = ? ",
                    new Object[] { new Long(customerId) },
                    new RowMapperResultReader(new StringRowMapper() ));
 
Author:
knoxg
  • Constructor Details

  • Method Details

    • mapRow

      public String mapRow(ResultSet resultSet, int rowNumber) throws SQLException
      Returns a single object representing this row.
      Specified by:
      mapRow in interface org.springframework.jdbc.core.RowMapper<String>
      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 restset is not a String or CLOB.
      SQLException