How to copy resultset into object?

后端 未结 2 668
渐次进展
渐次进展 2021-01-26 13:36

I am using the following to add retrieved values to the class. all values will be added to attributes of the class but I am using compisition ( have an object of class in the cl

2条回答
  •  天命终不由人
    2021-01-26 14:01

    The BeanProcessor.toBean works like this:

    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:

    • The class has a writable property with the same name as a column. The name comparison is case insensitive.
    • 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.

    May be the address is not a writable property. Pls do check it.

提交回复
热议问题