cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <...@maniatis.org>
Subject Re: Chainable SelectQuery
Date Mon, 06 Oct 2014 12:00:43 GMT
On 6/10/2014 2:10am, Andrus Adamchik wrote:
> // a single chain from query to object list
> List<Painting> paintings2 = SelectQuery.query(Painting.class, qualifier2).select(context);

Since we already have a constructor with the appropriate arguments, why not go for this as
the recommended approach:

    List<Painting> paintings2 = new SelectQuery(Painting.class, qualifier2).select(context);

I'm not really sure it makes a difference either way, but just throwing it out there. They
will both work, but the constructor doesn't have generics yet.


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

Can't we parse without any ambiguity:

    exp("artist.dateOfBirth < $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);

Let's see how this plays out with longer queries:

    List<Painting> paintings4 = SelectQuery.query(Painting.class, and(or(qualifier2,
qualifier3), qualifier4)).select(context);

That looks a bit like reverse Polish notation. To my mind, this approach is clearer:

    List<Painting> paintings4 = new SelectQuery(Painting.class).or(qualifier1).or(qualifier3).and(qualifier4).select(context);


Am I misunderstanding the different approaches to this? It appears both are valid with the
patch you are proposing. Also, I think the use of the words "qualifier" and "expression" are
confusing. We use them interchangeably without much reason. Can we pick one and stick to it?


Ari



-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Mime
View raw message