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
 
Daryl Stultz  
View profile   Translate to Translated (View Original)
 More options Mar 6 2010, 9:16 am
From: Daryl Stultz <kungfumachin...@gmail.com>
Date: Sat, 6 Mar 2010 06:16:20 -0800 (PST)
Local: Sat, Mar 6 2010 9:16 am
Subject: Re: Eager vs Lazy produces different results

On Mar 5, 5:00 pm, Rob Bygrave <robin.bygr...@gmail.com> wrote:

> I'd suggest that is a bug because you put the distinct in your query. Note
> there is a difference here with Ebean. With Ebean you don't need to specify
> the distinct as the persistence context is used during the building of the
> object graph ... and that by definition we can't have 2 (of the same) users.
> To me this is like JPA implementations are not using the persistence context
> during it's object graph construction which I find very strange

Yes, OpenJPA just slaps the DISTINCT on to the beginning of the query.
I haven't analyzed the query to determine why this doesn't work.

The results contain 2 copies of the user, but I'm sure the 2 are the
same instance. I'll modify the unit test when I get a chance to show
this.

> So now I'm thinking we can go two ways...
> Option 1.   stick with the current interpretation ... and force people to
> use subqueries and the like
> Option 2.   change to use the same interpretation as JPQL ... and provide
> some mechanism so that people that want to filter the many can do so.

I've really had a hard time trying to decide what side of this I want
to be on. I've decided I do not want the child list filtered. In SQL
you have complete control over all the result rows. You get to put
things together however you want. With Ebean ORM queries you are
asking for a collection of an entity. You are not responsible for the
"intermediate" child rows. You don't "see" them or "process" them. So
the "sense" is that you are only working with the root entity rows.
Therefore the criteria should refer to these rows only.

We talked about the case of Customers and Orders. I suggested
selecting Orders rather than Customers which leads to the problem of
organizing Orders by Customers. It seems like (a variation of?)
query.findMap() could take care of this:

query = Ebean.find(Order.class)...
query.setMapKey("customer");
Map<Customer, List<Order>> resultMap = query.findMap();

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