Subject RE: [Firebird-Java] FBResultSet proxy class on JBoss
Author Rick DeBay
> You should not cast to implementation class, only to interface.

I getClass() on the ResultSet I get back, because I need to use
introspection:

I have a DTO builder class that takes the data in a ResultSet and loads
it in to whatever Data Transfer Object that's passed in. The DTO may
have a setter that takes an int, but the value returned in the ResultSet
may be a VARCHAR, so I have to handle any combination of SQL values and
Java values as listed in the JDBC matrix. To do this I match ResultSet
getters to the DTO's setters, and to populate this matrix I use
introspection on the given ResultSet class to find all the getters.

The end result is that the methods in all my DAOs boil down to calling
one method:

Object[] execQuery(String sql, Object[] params, Class dto)

It took two days to write and test, with another half day to write the
extensions for MySql and Firebird to handle vendor idiosyncrasies.
Faster than learning and implementing JDO :-)

Rick DeBay

-----Original Message-----
From: Roman Rokytskyy [mailto:rrokytskyy@...]
Sent: Wednesday, December 22, 2004 5:12 PM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] FBResultSet proxy class on JBoss



> OK, so I'll have to handle getting more than one concrete ResultSet
> class.

You have to handle java.sql.ResultSet, nothing more. You should not cast
to
implementation class, only to interface.

Roman





Yahoo! Groups Links