I made a blog post how to do what you want here:
http://reumann.blogspot.com/2009/05/set-pojo-properties-with-groovy-sql-row.html
You just need the call toRowResult()
def getPersons() {
def persons = []
sql.eachRow("Select * from Person") {
persons << new Person( it.toRowResult() )
}
return persons
}
On Wed, Jul 1, 2009 at 12:59 PM, Tom Nichols
<tmnichols@...> wrote:
I thought it was possible to "map" a GroovyResultset to a POGO like this:
class Person {
String name
String address
}
def sql = Sql.newInstance(...)
def people = []
sql.eachRow( "select name, address from person" ).eachRow { people <<
new Person( it ) }
This would be possible if the GroovyResultSet were interpreted as a
Map, correct? i.e. the map would contain named properties that can
normally be passed to a constructor in Groovy. Would this be possible
by adding an asType(Map) to GroovyResultset?
Thanks.
-Tom
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
Rick R