I have a situation where I'm trying to pre-load a child collection so I won't have the N+1 select problem later.
I started by following the guidelines in this Blog post:
http://ayende.com/Blog/archive/2007/03/ ... rnate.aspx
Basically, the idea is to use the "left join fetch" syntax in my query to load the child collection. When I issue a query like this:
list = session.CreateQuery("from Blog blog left join fetch blog.Posts post" ).List();
instead of getting one item back for each Blog row, I get duplicate Blogs, one for each Post so the number of items in the list is equal to the total number of Posts, not the total number of Blogs.
If I change the mapping file to fetch="join" and lazy="false" then do a query with just "from Blog" I get the same behavior.
Changing the mapping file to fetch="subselect" gives me one entry in the list for each Blog as I expected with the original query.
Should the join fetch bring multiple copies of the parent object?