[
https://issues.apache.org/jira/browse/DBUTILS-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12672397#action_12672397
]
Dan Fabulich commented on DBUTILS-37:
-------------------------------------
I don't think it's necessary to create a separate OptimalBeanListHandler... I
think nobody should be using the old implementation.
I checked in a change to the "bugfixing" branch in revision 743097 that just
replaces the old implementation with this new faster implementation.
> BeanListHandler#handle(ResultSet) is not optimal
> ------------------------------------------------
>
> Key: DBUTILS-37
> URL: https://issues.apache.org/jira/browse/DBUTILS-37
> Project: Commons DbUtils
> Issue Type: Improvement
> Reporter: Julien Aymé
> Priority: Minor
> Attachments: OptimalBeanListHandler.java, OptimalBeanListHandler.patch
>
>
> I use the BeanListHandler for huge ResultSets (about 1000000 rows), and I
> searched through the code to see if I could gain little time.
> It appeared to me that the following code - in BeanProcessor.class - was
> executed too many times:
> {code}
> PropertyDescriptor[] props = this.propertyDescriptors(type);
> ResultSetMetaData rsmd = rs.getMetaData();
> int[] columnToProperty = this.mapColumnsToProperties(rsmd, props);
> {code}
> for the following reason.
> Since BeanListHandler extends GenericListHandler, the method
> #handle(ResultSet) calls #handleRow(ResultSet) for each row in the ResultSet,
> which in the case of a BeanListHandler, calls RowProcessor#toBean(ResultSet,
> Class),
> which itself calls BeanProcessor#toBean(ResultSet, Class).
> A very simple way to make the BeanListHandler#handle(ResultSet) method faster
> is to override the GenericListHandler#handle(ResultSet) method by this code:
> {code}
> public Object handle(ResultSet rs) throws SQLException {
> return this.convert.toBeanList(rs, type);
> }
> {code}
> This way, the code I showed would be called only once, as it would not call
> BeanProcessor#toBean(ResultSet, Class) for each row but
> BeanProcessor#toBeanList(ResultSet, Class).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.