On Thu, Oct 8, 2009 at 1:21 PM, Miłosz Tylenda <[email protected]> wrote:
> Hi Daryl, > > I can see the oddity but an "inversed" one. I would say that > > > // get em 1 > > select a from A as a > > left join fetch a.bCol > > // close em 1 > > should return 5 instances of A (2 x a1 and 3 x a2). Prefetching will not > make instances "distinct". > > Thanks for the feedback. It seems clear there's both a problem with my understanding as well as the implementation. From the manual: The following query returns a set of magazines. As a side effect, the associated articles for those magazines are also retrieved, even though they are not part of the explicit query result. The persistent fields or properties of the articles that are eagerly fetched are fully initialized. The initialization of the relationship properties of the articles that are retrieved is determined by the metadata for the Articleentity class. SELECT mag FROM Magazine mag LEFT JOIN FETCH mag.articles WHERE mag.id = 1 A fetch join has the same join semantics as the corresponding inner or outer join, except that the related objects specified on the right-hand side of the join operation are not returned in the query result or otherwise referenced in the query. Hence, for example, if magazine id 1 has five articles, the above query returns five references to the magazine 1 entity. The green part I understood to mean only one parent entity would be returned (the way my query works from a fresh start). The purple part seems to contradict the preceding green part and agrees with what you are suggesting. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
