db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wesley Biggs" <wes...@cacas.org>
Subject Re: Query closures for JDO 2.2
Date Sat, 01 Dec 2007 21:01:00 GMT
+1.  I like the "perform" term; it reinforces the abstraction of
"select these into Java, then perform this action" -- i.e. you get
side effects.

Wes

P.S. Your code example needs 1 + :percent instead of 1.06.

On 01/12/2007, Craig L Russell <Craig.Russell@sun.com> wrote:
> As you know, I'm not fond of the non-object style of query update,
> and there are cases where you want to do a bulk update efficiently in
> the datastore, but SQL just doesn't capture the object mapping that
> is used in the rest of the application.
>
> So what about defining a query closure, that is, declare a set of
> statements that is executed for each qualifying instance that
> satisfies the filter.
>
> This could execute in memory for memory collections, or in the
> datastore for non-instantiated collections. For portability we need
> to define the closure in terms that can be mapped directly to SQL.
>
> For example,
>
> PERFORM salary *= 1. + :percent; lastSalaryAdjustment = :date FROM
> Employee WHERE rating == :rating
>
> Query q = pm.newQuery(Employee, "rating > :rating");
> q.setPerform("salary *= 1.06; lastSalaryAdjustment = :date");
> q.execute(.06, new Date(), 7);
>
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>
>

Mime
View raw message