net.hasor.jdbc.core.mapper
类 ColumnMapRowMapper

java.lang.Object
  继承者 net.hasor.jdbc.core.mapper.ColumnMapRowMapper
所有已实现的接口:
RowMapper<Map<String,Object>>

public class ColumnMapRowMapper
extends Object
implements RowMapper<Map<String,Object>>

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.

从以下版本开始:
1.2
作者:
Juergen Hoeller
另请参见:
JdbcTemplate.queryForList(String), JdbcTemplate.queryForMap(String)

构造方法摘要
ColumnMapRowMapper()
           
 
方法摘要
protected  Map<String,Object> 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.
 Map<String,Object> mapRow(ResultSet rs, int rowNum)
          实现这个方法为结果集的一行记录进行转换,并将最终转换结果返回。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

ColumnMapRowMapper

public ColumnMapRowMapper()
方法详细信息

mapRow

public Map<String,Object> mapRow(ResultSet rs,
                                 int rowNum)
                          throws SQLException
从接口 RowMapper 复制的描述
实现这个方法为结果集的一行记录进行转换,并将最终转换结果返回。 如果返回为 null 等同于忽略该行。需要注意,不要调用结果集的 next() 方法。

指定者:
接口 RowMapper<Map<String,Object>> 中的 mapRow
抛出:
SQLException

createColumnMap

protected Map<String,Object> createColumnMap(int columnCount)
Create a Map instance to be used as column map.

By default, a linked case-insensitive Map will be created.

参数:
columnCount - the column count, to be used as initial capacity for the Map
返回:
the new Map instance
另请参见:
org.noe.platform.modules.db.jdbcorm.util.LinkedCaseInsensitiveMap

getColumnKey

protected String getColumnKey(String columnName)
Determine the key to use for the given column in the column Map.

参数:
columnName - the column name as returned by the ResultSet
返回:
the column key to use
另请参见:
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.

参数:
rs - is the ResultSet holding the data
index - is the column index
返回:
the Object returned
抛出:
SQLException
另请参见:
net.hasor.jdbc.jdbc.core.util.support.noe.platform.modules.db.jdbcorm.jdbc.support.JdbcUtils#getResultSetValue


Copyright © 2013-2014. All Rights Reserved.