| java.lang.Object liquibase.database.template.SingleColumnRowMapper
SingleColumnRowMapper | class SingleColumnRowMapper implements RowMapper(Code) | | 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.
author: Spring Framework |
Method Summary | |
protected Object | convertValueToRequiredType(Object value, Class requiredType) Convert the given column value to the specified required type.
Only called if the extracted column value does not match already.
If the required type is String, the value will simply get stringified
via toString() . | protected Object | getColumnValue(ResultSet rs, int index, Class requiredType) Retrieve a JDBC object value for the specified column.
The default implementation calls ResultSet.getString(index) etc
for all standard value types (String, Boolean, number types, date types, etc).
It calls ResultSet.getObject(index) else.
If no required type has been specified, this method delegates to
getColumnValue(rs, index) , which basically calls
ResultSet.getObject(index) but applies some additional
default conversion to appropriate value types.
Explicit extraction of a String is necessary to properly extract an Oracle
RAW value as a String, for example. | protected Object | getColumnValue(ResultSet rs, int index) Retrieve a JDBC object value for the specified column, using the most
appropriate value type. | public Object | mapRow(ResultSet rs, int rowNum) Extract a value for the single column in the current row. | public void | setRequiredType(Class requiredType) Set the type that each result object is expected to match. |
SingleColumnRowMapper | public SingleColumnRowMapper(Class requiredType)(Code) | | Create a new SingleColumnRowMapper.
Parameters: requiredType - the type that each result object is expected to match |
convertValueToRequiredType | protected Object convertValueToRequiredType(Object value, Class requiredType)(Code) | | Convert the given column value to the specified required type.
Only called if the extracted column value does not match already.
If the required type is String, the value will simply get stringified
via toString() . In case of a Number, the value will be
converted into a Number, either through number conversion or through
String parsing (depending on the value type).
Parameters: value - the column value as extracted from getColumnValue() (never null ) Parameters: requiredType - the type that each result object is expected to match(never null ) the converted value See Also: SingleColumnRowMapper.getColumnValue(java.sql.ResultSet,int,Class) |
getColumnValue | protected Object getColumnValue(ResultSet rs, int index, Class requiredType) throws SQLException(Code) | | Retrieve a JDBC object value for the specified column.
The default implementation calls ResultSet.getString(index) etc
for all standard value types (String, Boolean, number types, date types, etc).
It calls ResultSet.getObject(index) else.
If no required type has been specified, this method delegates to
getColumnValue(rs, index) , which basically calls
ResultSet.getObject(index) but applies some additional
default conversion to appropriate value types.
Explicit extraction of a String is necessary to properly extract an Oracle
RAW value as a String, for example. For the other given types, it is also
recommendable to extract the desired types explicitly, to let the JDBC driver
perform appropriate (potentially database-specific) conversion.
Parameters: rs - is the ResultSet holding the data Parameters: index - is the column index Parameters: requiredType - the type that each result object is expected to match(or null if none specified) the Object value See Also: java.sql.ResultSet.getString(int) See Also: java.sql.ResultSet.getObject(int) See Also: SingleColumnRowMapper.getColumnValue(java.sql.ResultSet,int) |
getColumnValue | protected Object getColumnValue(ResultSet rs, int index) throws SQLException(Code) | | Retrieve a JDBC object value for the specified column, using the most
appropriate value type. Called if no required type has been specified.
The default implementation delegates to JdbcUtils.getResultSetValue() ,
which uses the ResultSet.getObject(index) method. Additionally,
it includes a "hack" to get around Oracle returning a non-standard object for
their TIMESTAMP datatype. See the JdbcUtils#getResultSetValue()
javadoc for details.
Parameters: rs - is the ResultSet holding the data Parameters: index - is the column index the Object value |
setRequiredType | public void setRequiredType(Class requiredType)(Code) | | Set the type that each result object is expected to match.
If not specified, the column value will be exposed as
returned by the JDBC driver.
|
|
|