Re: "join fetch" doesnt work as expected

2011-02-22 Thread Craig L Russell
Hi, *The association referenced by the right side of the FETCH JOIN clause must be an association or element* *collection that is referenced from an entity or embeddable that is returned as a result of the query.* I didn't write the specification, but the way I read it, the right side of the F

Re: "join fetch" doesnt work as expected

2011-02-22 Thread Kevin Sutter
Hi Marc, If you can't tell, this question is making me curious... What if you changed your query to be like this: SELECT b FROM Box b JOIN FETCH b.order JOIN order o JOIN FETCH o.orderPositions WHERE b.id = ?1 I don't even know if this will be processed correctly or if it's "legal" per the spec,

Re: "join fetch" doesnt work as expected

2011-02-22 Thread Kevin Sutter
I looked at our existing junit tests and it looks like we're testing a single level of fetching. That is, if b <-> orders was 1:n instead of 1:1, then you could do the "JOIN FETCH b.orders". It looks like we have tested that processing. But, not going multiple levels... If I look at the spec (s

Re: "join fetch" doesnt work as expected

2011-02-22 Thread Kevin Sutter
Hmmm... It's my understanding that a JOIN FETCH should preload the relationship, even if it's marked as being Lazy. Have you performed a SQL trace to see if we're even attempting to load the relationship? Unless someone else speaks up, this would seem to be a bug. Kevin On Tue, Feb 22, 2011 at

"join fetch" doesnt work as expected

2011-02-22 Thread Marc Logemann
Hi, assume this code: Query query = getEntityManager().createQuery("SELECT b FROM Box b JOIN FETCH b.order.orderPositions WHERE b.id = ?1"); query.setParameter(1, boxId); List boxList = query.getResultList(); The relationship is: box <-- 1:1 ---> order <-- 1:n --> orde