Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion Eager vs Lazy produces different results
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rob Bygrave  
View profile  
 More options Mar 5 2010, 5:11 pm
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Sat, 6 Mar 2010 11:11:52 +1300
Local: Fri, Mar 5 2010 5:11 pm
Subject: Re: [ebean] Re: Eager vs Lazy produces different results

subquery() ... could create a Query and return that queries expression list
... aka ... where()

// returns the expressionList of the subquery
// ... so you can add any number of criteria to the subquery

ExpressionList<T> subquery() {
     String idPropertyName = ...

     Query<T> subquery = ...
     subquery.select(idPropertyName);

     // id in (select id from MyType where ........)
     in(idPropertyName, subQuery);

     return subQuery.where();

}
> How would things "switch back" to the root query

Not sure of the best way ...  you could just say... don't go fluid which is
probably fine.

// so we can refer to the 'root' query ...
Query<User> userQuery = Ebean.find(User.class);

userQuery.where().subquery().in("validRoles.name", roleNames);

// we need to add more criteria to the 'root' query (not the subquery)
userQuery.where().ilike("name", "Rob%")

On Sat, Mar 6, 2010 at 5:51 AM, Daryl Stultz <kungfumachin...@gmail.com>wrote:

> > We could for example do...
> >Ebean.find(User.class)
> >   .where().*subquery()*.in("validRoles.id",myRoles)
> >   .findList();
> >I'm not sure about "subquery()"

> I can see something like subquery() being generally useful - not just
> in the case of *toMany. As you've written subquery().in, something
> like subquery().eq would be useful, too. Not sure how chaining should
> work, if you want more than one criteria in the subquery. How would
> things "switch back" to the root query (how would you add more
> criteria, maybe even another subquery, on the root where).

> /Daryl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.