Brian's Waste of Time

Sun, 16 Nov 2003

Thinking About Queries

I got into a very fun discussion with James Strachan about Groovy Data Objects -- which are modeled more after ADO than JDO. GDO looks like

collection.select { where { b > 100 && b < 5000 } orderBy { ascending { [ b, c] } desceding { x } }

Or, for projections

collection.select { property b { get { bar.order.amount} set { bar.order.amount = it } } where { b > 100 && b < 5000 } orderBy { ascending { [ b, c] } desceding { x } }

The idea of a query as an closure is appealing. I may have to try to do a GDO style query-as-closure for OJB during the hackathon. Groovy provides access to the AST of GroovyObjects, so traversing that building a query-by-criteria shouldn't be terrible. Off to code I go.

0 writebacks [/src/java/ojb] permanent link