(NHibernate 2.0.1 GA)
I am trying to setup eager loading for one of my collections (simple one-to-many) and am having some problems.
My set is defined within an entity called Category as follows: -
Code:
<set name="CategoryValues" inverse="true" fetch="join" >
<key column="CategoryID" />
<one-to-many class="CategoryValue" />
</set>
I can load a Category class but if I try to access the CategoryValues set after the session is closed, I get the following error: -
Code:
failed to lazily initialize a collection, no session or session was closed
In reading Hibernate In Action, fetch="join" should disable lazy loading but it does not appear to in this case. I'm not sure if this is a difference between Hibernate and NHibernate.
I can add the lazy="false" attribute and eager loading works. However, even though I have fetch="join", the SQL executed is a series of SELECT statements, one for each CategoryValue. I.e. not a join.
I have the same issue using fetch="join" on a many-to-one property.