cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <...@maniatis.org>
Subject Re: new fluent API
Date Wed, 15 Apr 2015 08:06:24 GMT
On 15/04/2015 5:12pm, Andrus Adamchik wrote:
> Perhaps we just don't allow "reset" operations in the new API at all? 

I think that would be clearer. Except for the obvious things like cache strategy where you
can't have two at once.


> "where" sets a new qualifier. However we also have "and" and "or" that append to the
existing one, so your example may look like this:
>>
>> List<Contact> users = ObjectSelect.query(Contact.class)
>> .where(Contact.EMAIL_ADDRESS.eq(email))
>> .and(Contact.COLLEGE.eq(college))
>> .and(Contact.GIVEN_NAME.eq(firstName))
>> .or(Contact.LAST_NAME.eq(lastName)))
>> .select(context);

Oops. I completely missed those! I think that goes a long way toward solving the readability
issue. You can even write (with some loss of readability):

   List<Contact> users = ObjectSelect.query(Contact.class)
        .and(Contact.EMAIL_ADDRESS.eq(email));

This can be useful when you pass queries around between functions or inside conditions and
loops. In my opinion, "where" should be an alias of "and".



Anyhow, the big takeaway is that for me in my little migration, the new API is really really
nice.

Ari


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

Mime
View raw message