6 Apr 2004 11:30
using properties on ResultSet (was Re: Properties)
On 5 Apr 2004, at 23:21, bing ran wrote: > Actually getAt() is not part of List interface. List has get(int). So > List actually adheres to JavaBeans patterns (and is not a Java bean). > > I'm wondering what would it gets us if I use the property accessor - > the > "." - on an object of ResultSet, which has lots of getXXX() and that > obviously are not bean accesors. Actually thats what GroovyResultSet does :) It overloads the property access mechanism to provide access to named columns in the result set (i.e. providing getProperty()/setProperty()). Also it overloads getAt() setAt() so you can use integer subscripting into columns too... http://tinyurl.com/34dn6 // property access sql.eachRow("select * from PERSON") { println("Hello ${it.firstname} ${it.lastname}") } // index access sql.eachRow("select count(*) from PERSON") { answer = it[0] } James ------- http://radio.weblogs.com/0112098/
RSS Feed