|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.core.SingleColumnRowMapper
public class SingleColumnRowMapper
RowMapper implementation that converts a single column into a single result value per row. Expects to work on a ResultSet that just contains a single column.
The type of the result value for each row can be specified. The value for the single column will be extracted from the ResultSet and converted into the specified target type.
JdbcTemplate.queryForList(String, Class)
,
JdbcTemplate.queryForObject(String, Class)
Constructor Summary | |
---|---|
SingleColumnRowMapper()
Create a new SingleColumnRowMapper. |
|
SingleColumnRowMapper(Class requiredType)
Create a new SingleColumnRowMapper. |
Method Summary | |
---|---|
protected Object |
getColumnValue(ResultSet rs,
int index)
Retrieve a JDBC object value for the specified column. |
Object |
mapRow(ResultSet rs,
int rowNum)
Implementations must implement this method to map each row of data in the ResultSet. |
void |
setRequiredType(Class requiredType)
Set the type that each result object is expected to match. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SingleColumnRowMapper()
setRequiredType(java.lang.Class)
public SingleColumnRowMapper(Class requiredType)
requiredType
- the type that each result object is expected to matchMethod Detail |
---|
public void setRequiredType(Class requiredType)
If not specified, the column value will be exposed as returned by the JDBC driver.
public Object mapRow(ResultSet rs, int rowNum) throws SQLException
RowMapper
mapRow
in interface RowMapper
rs
- the ResultSet to maprowNum
- The number of the current row
SQLException
- if a SQLException is encountered getting
column values (that is, there's no need to catch SQLException)protected Object getColumnValue(ResultSet rs, int index) throws SQLException
The default implementation uses the getObject
method.
Additionally, this implementation includes a "hack" to get around Oracle
returning a non-standard object for their TIMESTAMP datatype.
rs
- is the ResultSet holding the dataindex
- is the column index
SQLException
JdbcUtils.getResultSetValue(java.sql.ResultSet, int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |