I'm using NHibernate version 1.2.0.Beta1 and have a simple one-many relationship defined roughly like this:
<class name="Parent" table="parent" lazy="false" mutable="false">
<id column="parent_id" name="ParentID" type="Int32">
<generator class="identity" />
</id>
<list name="ChildList" table="children" lazy="false" fetch="join">
<key column="parent_id" />
<index column="idx" />
<one-to-many class="Child"/>
</list>
</class>
<class name="Child" table="exceptions" lazy="false" mutable="false" >
<id column="child_id" name="ChildID" type="Int32">
<generator class="identity" />
</id>
<!-- properties -->
</class>
When I first tried this mapping I did not use fetch="join" on the collection and everything was working fine, but the iterative queries were simply too expensive. However, when I added the fetch="join" argument, I started seeing a LazyInitializationException inside of the ChildList property setter. The setter called the Count method of the collection and was getting the error "cannot access loading collection".
This one has me a bit stumped.. any advice would be appreciated.
|