pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Create a pivot.sql.ResultSetAdapter class
Date Tue, 14 Apr 2009 16:33:44 GMT
>this is a sample usage as anonymous inner classes (taken from here
>http://static.springframework.org/spring/docs/2.5.x/reference/jdbc.html
>):
>
>public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
>            Actor actor = new Actor();
>            actor.setFirstName(rs.getString("first_name"));
>            actor.setSurname(rs.getString("surname"));
>            return actor;
>        }

What I'm envisioning is a bit simpler. No need to write mapper classes - just wrap your ResultSet
in an instance of ResultSetAdapter and pass it to writeObject(). What we need is a way to
specify:

- the source column name
- the desired field name for the output (i.e. the map key)
- the desired type of the output (so we know which ResultSet getter to invoke

I think this can be specified using internal classes such as Field and FieldSequence, where
Field contains the above information and FieldSequence is an internal collection that contains
the desired fields.

If we do decide that wrapping ResultSet is preferable to RowSet, you should probably return
-1 from getLength() so a caller can tell that the iterator must be used.




Mime
View raw message