Package liquibase.executor.jvm
Class ColumnMapRowMapper
- java.lang.Object
-
- liquibase.executor.jvm.ColumnMapRowMapper
-
- All Implemented Interfaces:
RowMapper
public class ColumnMapRowMapper extends Object implements RowMapper
RowMapper
implementation that creates ajava.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)
andgetColumnKey(java.lang.String)
, respectively.
-
-
Constructor Summary
Constructors Constructor Description ColumnMapRowMapper(boolean caseSensitiveDatabase)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
mapRow
public Object mapRow(ResultSet rs, int rowNum) throws SQLException
Description copied from interface:RowMapper
Implementations must implement this method to map each row of data in the ResultSet. This method should not callnext()
on the ResultSet; it is only supposed to map values of the current row.- Specified by:
mapRow
in interfaceRowMapper
- Parameters:
rs
- the ResultSet to map (pre-initialized for the current row)rowNum
- the number of the current row- Returns:
- the result object for the current row
- Throws:
SQLException
- if a SQLException is encountered getting column values (that is, there's no need to catch SQLException)
-
createColumnMap
protected Map createColumnMap(int columnCount)
Create a Map instance to be used as column map.- Parameters:
columnCount
- the column count, to be used as initial capacity for the Map- Returns:
- the new Map instance
-
getColumnKey
protected String getColumnKey(String columnName)
Determine the key to use for the given column in the column Map.- Parameters:
columnName
- the column name (uppercase) as returned by the ResultSet- Returns:
- the column key to use
- See Also:
ResultSetMetaData.getColumnName(int)
-
getColumnValue
protected Object getColumnValue(ResultSet rs, int index) throws SQLException
Retrieve a JDBC object value for the specified column.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.- Parameters:
rs
- is the ResultSet holding the dataindex
- is the column index- Returns:
- the Object returned
- Throws:
SQLException
-
-