net.hasor.jdbc.core.mapper
类 BeanPropertyRowMapper<T>

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

public class BeanPropertyRowMapper<T>
extends Object
implements RowMapper<T>

用于 POJO 的 RowMapper

版本:
: 2013-12-18
作者:
赵永春(zyc@hasor.net)

构造方法摘要
BeanPropertyRowMapper()
          Create a new BeanPropertyRowMapper.
BeanPropertyRowMapper(Class<T> requiredType)
          Create a new BeanPropertyRowMapper.
 
方法摘要
protected  Object getColumnValue(ResultSet rs, int index)
          Retrieve a JDBC object value for the specified column, using the most appropriate value type.
protected  Object getColumnValue(ResultSet rs, int index, Class requiredType)
          Retrieve a JDBC object value for the specified column.
 boolean isCaseInsensitive()
           
 T mapRow(ResultSet rs, int rowNum)
          实现这个方法为结果集的一行记录进行转换,并将最终转换结果返回。
static
<T> BeanPropertyRowMapper<T>
newInstance(Class<T> mappedClass)
          Static factory method to create a new BeanPropertyRowMapper (with the mapped class specified only once).
 void setCaseInsensitive(boolean caseInsensitive)
           
 void setRequiredType(Class<T> requiredType)
          Set the type that each result object is expected to match.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

BeanPropertyRowMapper

public BeanPropertyRowMapper()
Create a new BeanPropertyRowMapper.

另请参见:
setRequiredType(java.lang.Class)

BeanPropertyRowMapper

public BeanPropertyRowMapper(Class<T> requiredType)
Create a new BeanPropertyRowMapper.

参数:
requiredType - the type that each result object is expected to match
方法详细信息

setRequiredType

public void setRequiredType(Class<T> requiredType)
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.


isCaseInsensitive

public boolean isCaseInsensitive()

setCaseInsensitive

public void setCaseInsensitive(boolean caseInsensitive)

mapRow

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

指定者:
接口 RowMapper<T> 中的 mapRow
抛出:
SQLException

getColumnValue

protected Object getColumnValue(ResultSet rs,
                                int index,
                                Class requiredType)
                         throws SQLException
Retrieve a JDBC object value for the specified column.

The default implementation calls JdbcUtils.getResultSetValue(java.sql.ResultSet, int, Class). 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.

参数:
rs - is the ResultSet holding the data
index - is the column index
requiredType - the type that each result object is expected to match (or null if none specified)
返回:
the Object value
抛出:
SQLException - in case of extraction failure
另请参见:
net.hasor.jdbc.jdbc.core.util.support.noe.platform.modules.db.jdbcorm.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class), getColumnValue(java.sql.ResultSet, int)

getColumnValue

protected Object getColumnValue(ResultSet rs,
                                int index)
                         throws SQLException
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.

参数:
rs - is the ResultSet holding the data
index - is the column index
返回:
the Object value
抛出:
SQLException - in case of extraction failure
另请参见:
net.hasor.jdbc.jdbc.core.util.support.noe.platform.modules.db.jdbcorm.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int)

newInstance

public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass)
Static factory method to create a new BeanPropertyRowMapper (with the mapped class specified only once).

参数:
mappedClass - the class that each row should be mapped to


Copyright © 2013-2014. All Rights Reserved.