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 3 2010, 9:48 pm
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Thu, 4 Mar 2010 15:48:59 +1300
Local: Wed, Mar 3 2010 9:48 pm
Subject: Re: [ebean] Eager vs Lazy produces different results

> JPA would always return the entire list of validRoles.

Ok, how about a different example ...

Lets say you have customers and each customer can have 10000's of orders...

...  I want to filter the customer orders to just get the Order.Status.NEW
ones since last week (for all the customers starting with 'A%'. I don't want
to blindly get all the orders for each customer because there could be
thousands of them and I'm only interested in the new orders.

find customer
join orders
where name like :customerName
  and orders.status = :orderStatus
  and orders.orderDate > :lastWeek

Aka ... sometimes you don't want ALL beans on a given path.

Does this example make sense?

On Thu, Mar 4, 2010 at 3:03 PM, Daryl Stultz <kungfumachin...@gmail.com>wrote:

> Hello,

> Consider the following:

> User user = new User();
> user.setName("user");
> Ebean.save(user);

> Role role1 = new Role();
> role1.setName("role1");
> Ebean.save(role1);
> user.getValidRoles().add(role1);
> Role role2 = new Role();
> role2.setName("role2");
> Ebean.save(role2);
> user.getValidRoles().add(role2);
> Ebean.save(user);

> List<Integer> roleIds = new ArrayList<Integer>();
> roleIds.add(role1.getId());
> List<User> result =
> Ebean.find(User.class).join("validRoles").where().in("validRoles.id",
> roleIds).findList();
> assertEquals(1, result.size());
> User resultUser = result.get(0);
> assertEquals(user, resultUser);
> assertEquals(2, resultUser.getValidRoles().size());

> It returns only the valid roles that are in the roleIds list. If I
> remove join("validRoles") from the query, the validRoles collection is
> lazy loaded (both roles) and the test passes. Surely this difference
> indicates a bug? JPA would always return the entire list of
> validRoles.

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