Package com.randomnoun.common.spring
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
StringRowMapper
public StringRowMapper()
-
-
Method Details
-
mapRow
Returns a single object representing this row.- Specified by:
mapRow
in interfaceorg.springframework.jdbc.core.RowMapper<String>
- Parameters:
resultSet
- The resultset to maprowNumber
- 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
-