|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.jdbc.core.ColumnMapRowMapper
public class ColumnMapRowMapper
RowMapper implementation that creates a java.util.Map
for each row, representing all columns as key-value pairs: one
entry for each column, with the column name as key.
The Map implementation to use and the key to use for each column
in the column Map can be customized through overriding
createColumnMap
and getColumnKey
, respectively.
createColumnMap(int)
,
getColumnKey(java.lang.String)
,
JdbcTemplate.queryForList(String)
,
JdbcTemplate.queryForMap(String)
Constructor Summary | |
---|---|
ColumnMapRowMapper()
|
Method Summary | |
---|---|
protected Map |
createColumnMap(int columnCount)
Create a Map instance to be used as column map. |
protected String |
getColumnKey(String columnName)
Determine the key to use for the given column in the column Map. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ColumnMapRowMapper()
Method Detail |
---|
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 Map createColumnMap(int columnCount)
By default, a linked case-insensitive Map will be created if possible, else a plain HashMap (see Spring's CollectionFactory).
columnCount
- the column count, to be used as initial
capacity for the Map
CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(int)
protected String getColumnKey(String columnName)
columnName
- the column name as returned by the ResultSet
ResultSetMetaData.getColumnName(int)
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 |