You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Hardy, Derek" <De...@astrazeneca.com> on 2003/07/21 12:49:27 UTC
[beanUtils] Incorrect number of rows when creating a ResultSetDyn
aClass from a ResultSet
Hi
I'm using the "standard/example" code to copy a series of values from a
result set (based on a query to an Oracle database) into an ArrayList for
later use.
The code is as follows
ResultSet rs = stmt.executeQuery(sql);
ArrayList results = new ArrayList();
ResultSetDynaClass rss = new ResultSetDynaClass(rs);
BasicDynaClass bdc =
new BasicDynaClass("foo", BasicDynaBean.class,
rss.getDynaProperties());
Iterator rows = rss.iterator();
while (rows.hasNext()) {
DynaBean oldRow = (DynaBean) rows.next();
DynaBean newRow = bdc.newInstance();
PropertyUtils.copyProperties(newRow, oldRow);
results.add(newRow);
}
But there only seems to be one row in the results ArrayList, despite there
being 5 rows in the database.
Does anybody know why this could be so?
Thanks in advance.
Derek