> On Apr 15, 2015, at 9:57 AM, Aristedes Maniatis <[email protected]> wrote:
> 1. Before
>
>
>
> The main lack of clarity here is "lt". Is it worth having an alias "before"
> for "lt"?
>
> where(SupportPassword.EXPIRES_ON.before(new Date())).
Wouldn't "before" only apply to dates? What if it is an Integer?
> 2. Lots of AND
>
> List<Contact> users = ObjectSelect.query(Contact.class).
> where(Contact.EMAIL_ADDRESS.eq(email).
> andExp(Contact.COLLEGE.eq(college)).
> andExp(Contact.GIVEN_NAME.eq(firstName)).
> andExp(Contact.LAST_NAME.eq(lastName))).
> select(context);
>
> You can easily get lost in all those brackets, especially for more complex
> expressions than above. Would it make sense to write this:
>
> List<Contact> users = ObjectSelect.query(Contact.class).
> where(Contact.EMAIL_ADDRESS.eq(email).
> where(Contact.COLLEGE.eq(college)).
> where(Contact.GIVEN_NAME.eq(firstName)).
> where(Contact.LAST_NAME.eq(lastName))).
> select(context);
"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);
> Also, and probably more importantly, ordering like this makes sense:
>
> List<Contact> users =
> query.order(Contact.GIVEN_NAME.asc()).order(Contact.LAST_NAME.asc()).select(context);
Here also we have separate methods for resetting ordering and for appending to
the existing ones:
List<Contact> users = query
.orderBy(Contact.GIVEN_NAME.asc())
.addOrderBy(Contact.LAST_NAME.asc())
.select(context);
(Same with prefetching). Unfortunately this is a bit confusing, but I could not
think of another way to allow both "reset" and "append" operations.
Andrus