@ThreadSafe
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.
BasicRowProcessor
Constructor and Description |
---|
BeanProcessor()
Constructor for BeanProcessor.
|
Modifier and Type | Method and Description |
---|---|
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. |
public java.lang.Object toBean(java.sql.ResultSet rs, java.lang.Class type) throws java.sql.SQLException
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:
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 datatype
- Class from which to create the bean instancejava.sql.SQLException
- if a database access error occurspublic java.util.List toBeanList(java.sql.ResultSet rs, java.lang.Class type) throws java.sql.SQLException
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:
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 datatype
- Class from which to create the bean instancejava.sql.SQLException
- if a database access error occurs