From: Daryl Stultz <kungfumachin...@gmail.com>
Date: Thu, 4 Mar 2010 18:24:32 -0800 (PST)
Local: Thurs, Mar 4 2010 9:24 pm
Subject: Re: Eager vs Lazy produces different results
On Mar 4, 8:07 pm, Rob Bygrave <robin.bygr...@gmail.com> wrote: > > I was surprised - you always get the whole list. ... subquery illustration > I'd suggest what you wanted to do was more like: > Personally I have a SQL bias and I'd suggest the reason you where the same conclusion. If my original query was an API for generating SQL, I'd totally expect it to filter the children. I even put a comment in my code that I might have to convert the criteria to a subquery. I'm thinking that people (like me) coming from JPA are going to be > That is, when you do the JPA query and see the generated SQL I'd Yes that's what I expected to see, and I'm sure I've seen it in some > expect to see a subquery used to limit the users - cases, but I can't dig one up quickly. My first attempt was straight JPA with a join fetch. This produced a double cartesian of the root with the children, even with DISTINCT. Anyway, here's the test case: User user = setup.insertUser("user1"); List<Integer> roleIds = new ArrayList<Integer>(); Query query = ExecutionResources.getEntityManager().createQuery( List<User> result = query.getResultList(); JpaUtils.addFetchFields takes advantage of fetch plan manipulation to SELECT DISTINCT t0.userid, ... SELECT DISTINCT t0.userid... It looks a bit whacky to me, double joining the child tables. Not sure > and the question Yup, I hear ya. Looks like that's where I'm going... > becomes ... if you want to end up with a sql subquery... why not use > an subquery with the ORM query in the same way? > Yup - that is going to be a bug - but firstly I want to get to the Just so we're clear, the default join/fetch produces a filtered child > bottom of the *ToMany filtering. Specifically I want to check the sql > that the jpa query generates. set, the default lazy load produces a full set and the JoinConfig().query() produces a full set. /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.
| ||||||||||||||