cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Chainable SelectQuery
Date Sun, 05 Oct 2014 15:10:09 GMT
In preparation to 3.2.M2, I am working on polishing our new query APIs. Good examples of the
new API are a new SelectById query [1] and of course previously available SQLSelect. Now started
working on SelectQuery, which is a more subtle matter as it affects every single Cayenne user.
So instead of committing it right away, I created a pull request #16 [2] and now would like
to hear comments before this goes to the main repo.

This changes SelectQuery and tweaks ExpressionFactory and Expression. You get the most milage
out of it if you statically import ExpressionFactory. A good example is the Main file from
our tutorials [3]:

// static imports
import static org.apache.cayenne.exp.ExpressionFactory.exp;
import static org.apache.cayenne.exp.ExpressionFactory.or;

// a single chain from query to object list
List<Painting> paintings2 = SelectQuery.query(Painting.class, qualifier2).select(context);

// static use of "exp" (former "Expression.fromString")
// immediate parameter binding
Expression qualifier3 = exp("artist.dateOfBirth < $date", "date", c.getTime());

// static use of 'or' seems cleaner than chaining expressions with 'exp.orExp(..)'
List<Painting> paintings4 = SelectQuery.query(Painting.class, or(qualifier2, qualifier3)).select(context);



View raw message