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(int) and getColumnKey(java.lang.String), 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. This requires Commons Collections on the classpath (which will be autodetected). Else, the fallback is a standard linked HashMap, which will still preserve column order but requires the application to specify the column names in the same casing as exposed by the driver.
- Since:
- 2.0
- Author:
- Mark Paluch
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateColumnMap(int columnCount) Create aMapinstance to be used as column map.protected StringgetColumnKey(String columnName) Determine the key to use for the given column in the column Map.protected ObjectgetColumnValue(com.datastax.oss.driver.api.core.cql.Row row, int index) Retrieve a CQL object value for the specified column.mapRow(com.datastax.oss.driver.api.core.cql.Row rs, int rowNum) Implementations must implement this method to map each row of data in theResultSet.
-
Constructor Details
-
ColumnMapRowMapper
public ColumnMapRowMapper()
-
-
Method Details
-
mapRow
Description copied from interface:RowMapperImplementations must implement this method to map each row of data in theResultSet. -
createColumnMap
Create aMapinstance to be used as column map.By default, a linked case-insensitive Map will be created.
- Parameters:
columnCount- the column count, to be used as initial capacity for theMap, must not be null.- Returns:
- the new Map instance.
- See Also:
-
getColumnKey
Determine the key to use for the given column in the column Map.- Parameters:
columnName- the column name as returned by theRow, must not be null.- Returns:
- the column key to use.
- See Also:
-
ColumnDefinitions.get(int)
-
getColumnValue
Retrieve a CQL object value for the specified column.The default implementation uses the
getObjectmethod.- Parameters:
row- is theRowholding the data, must not be null.index- is the column index.- Returns:
- the Object returned
-