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 by overriding createColumnMap
and getColumnKey, respectively.
Note
By default, ColumnMapRowMapper will try to build a linked Map
with case-insensitive keys, to preserve column order as well as allow any
casing to be used for column names.
JdbcTemplate#queryForList(String), JdbcTemplate#queryForMap(String)
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Map | Returns: the new Map instancethe column count, to be used as initial
capacity for the Map columnCount)Create a Map instance to be used as column map. |
| protected String | Returns: the column key to usethe column name as returned by the ResultSet columnName)Determine the key to use for the given column in the column Map. |
| protected Object | Returns: the Object returnedthe ResultSet holding the data rs, int the column index index)Retrieve a JDBC object value for the specified column. |
| public Map | mapRow(ResultSet
the rs, int ResultSet to map (pre-initialized for the current row)the number of the current row rowNum)Implements org. Implementations must implement this method to map each row of data in the
|
| ColumnMapRowMapper | back to summary |
|---|---|
| public ColumnMapRowMapper() | |
| createColumnMap | back to summary |
|---|---|
| protected Map Create a Map instance to be used as column map. By default, a linked case-insensitive Map will be created.
| |
| getColumnKey | back to summary |
|---|---|
| protected String getColumnKey(String columnName) Determine the key to use for the given column in the column Map. By default, the supplied column name will be returned unmodified.
| |
| getColumnValue | back to summary |
|---|---|
| protected Object getColumnValue(ResultSet rs, int index) throws SQLException Retrieve a JDBC object value for the specified column. The default implementation uses the
| |
| mapRow | back to summary |
|---|---|
| public Map Implements org. Doc from org. Implementations must implement this method to map each row of data in the
| |