Dear Struts Experts,
I recently started a new project where most of the backend code is already
written with JDBC and ResultSets. The ResultSets are iterated through and a
POJOs values are set using pojo.setName(rs.getString("...")), etc. - you get
the point. I'm wondering if there's an easier way - so I could do something
like this:
ResultSet rs = stmt.executeQuery("SELECT ...");
List objects = FancyUtilitity.convertResultSetToListOfObjects(rs,
object.class);
Hibernate let me do this very simply - and I miss the fact that I could type
a line or two to get a List of POJOs.
List users = ses.createQuery("from u in class " + User.class
+ "order by u.name").list();
I've looked at the RowSetDynaClass (http://tinyurl.com/mekh), which has an
interesting way of doing this - is this the "recommended" approach in the
JDBC world? Here's an example using it:
ResultSet rs = stmt.executeQuery("SELECT ...");
RowSetDynaClass rsdc = new RowSetDynaClass(rs);
rs.close();
stmt.close();
...; // Return connection to pool
List rows = rsdc.getRows();
...; // Process the rows as desired
Thanks,
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]