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 4 2010, 8:07 pm
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Thu, 4 Mar 2010 17:07:53 -0800 (PST)
Local: Thurs, Mar 4 2010 8:07 pm
Subject: Re: Eager vs Lazy produces different results

> I was surprised - you always get the whole list.

I'd suggest what you wanted to do was more like:

List<Integer> myRoles = ...;
Query<User> subquery =
Ebean.find(User.class).select("id").where().in("validRoles.id",
myRoles);

Ebean.find(User.class)
    .where().in("id", subquery)
    .findList();

Personally I have a SQL bias and I'd suggest the reason you where
suprised is because the ORM translated the query into sql that
filtered the users (root level object) and not filtered the *ToMany
(validRoles).

That is, when you do the JPA query and see the generated SQL I'd
expect to see a subquery used to limit the users - and the question
becomes ... if you want to end up with a sql subquery... why not use
an subquery with the ORM query in the same way?

That said...  lets make sure we are talking about the exact same thing
when we have the JPA query and the sql it generates... we can put that
side by side with the orm query - and hopefully that clarifies it.

> the second part of my complaint - eager does not produce the same as lazy

Yup - that is going to be a bug - but firstly I want to get to the
bottom of the *ToMany filtering. Specifically I want to check the sql
that the jpa query generates.

Cheers, Rob.

On Mar 5, 10:27 am, Daryl Stultz <kungfumachin...@gmail.com> wrote:

> On Mar 4, 3:37 pm, Rob Bygrave <robin.bygr...@gmail.com> wrote:

> > So, lets say each customer had tens of thousands of Orders
> > you have some work to do to find
> > the list of unique customers first and then ...

> Yes, I understand the challenge. As I said, when I first found that
> JPA did NOT filter the list I was surprised - you always get the whole
> list. Likewise, I was surprised that Ebean filtered the list. I
> definitely see it being useful to filter the list. My main point here
> is that I didn't *think* I was asking for a filtered list. Sometimes
> you want it one way, sometimes the other, and it needs to be clear
> what will happen. Perhaps the default should be to load it all to be
> consistent with JPA and JoinConfig should be used to specify that it
> should be filtered. Not sure that's the "Ebean way" to do it, but you
> see what I mean.

> > > JoinConfig().query() ...

> > Hmmm, I'll have a look at that (I'd suggest that is a bug).

> Yes, that's the second part of my complaint - eager does not produce
> the same as lazy. It seems like it would be easier to make eager
> return all than lazy return filtered, but that's your problem,
> right? :-)

> I'll try to put together a JPA example tonight.

> /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.