org.apache.commons.dbutils
クラス BeanProcessor

java.lang.Object
  上位を拡張 org.apache.commons.dbutils.BeanProcessor

public class BeanProcessor
extends java.lang.Object

BeanProcessor matches column names to bean property names and converts ResultSet columns into objects for those bean properties. Subclasses should override the methods in the processing chain to customize behavior.

This class is thread-safe.

導入されたバージョン:
DbUtils 1.1
関連項目:
BasicRowProcessor

コンストラクタの概要
BeanProcessor()
          Constructor for BeanProcessor.
 
メソッドの概要
 java.lang.Object toBean(java.sql.ResultSet rs, java.lang.Class type)
          Convert a ResultSet row into a JavaBean.
 java.util.List toBeanList(java.sql.ResultSet rs, java.lang.Class type)
          Convert a ResultSet into a List of JavaBeans.
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

BeanProcessor

public BeanProcessor()
Constructor for BeanProcessor.

メソッドの詳細

toBean

public java.lang.Object toBean(java.sql.ResultSet rs,
                               java.lang.Class type)
                        throws java.sql.SQLException
Convert a ResultSet row into a JavaBean. This implementation uses reflection and BeanInfo classes to match column names to bean property names. Properties are matched to columns based on several factors:
  1. The class has a writable property with the same name as a column. The name comparison is case insensitive.
  2. The column type can be converted to the property's set method parameter type with a ResultSet.get* method. If the conversion fails (ie. the property was an int and the column was a Timestamp) an SQLException is thrown.

Primitive bean properties are set to their defaults when SQL NULL is returned from the ResultSet. Numeric fields are set to 0 and booleans are set to false. Object bean properties are set to null when SQL NULL is returned. This is the same behavior as the ResultSet get* methods.

パラメータ:
rs - ResultSet that supplies the bean data
type - Class from which to create the bean instance
戻り値:
the newly created bean
例外:
java.sql.SQLException - if a database access error occurs

toBeanList

public java.util.List toBeanList(java.sql.ResultSet rs,
                                 java.lang.Class type)
                          throws java.sql.SQLException
Convert a ResultSet into a List of JavaBeans. This implementation uses reflection and BeanInfo classes to match column names to bean property names. Properties are matched to columns based on several factors:
  1. The class has a writable property with the same name as a column. The name comparison is case insensitive.
  2. The column type can be converted to the property's set method parameter type with a ResultSet.get* method. If the conversion fails (ie. the property was an int and the column was a Timestamp) an SQLException is thrown.

Primitive bean properties are set to their defaults when SQL NULL is returned from the ResultSet. Numeric fields are set to 0 and booleans are set to false. Object bean properties are set to null when SQL NULL is returned. This is the same behavior as the ResultSet get* methods.

パラメータ:
rs - ResultSet that supplies the bean data
type - Class from which to create the bean instance
戻り値:
the newly created List of beans
例外:
java.sql.SQLException - if a database access error occurs