Problem:
(See the mapping below for the class definitions)
After loading and evicting the AppList object, I'm then trying to load a particluar AppListItem. The problems is that Attributes bag is not filled for the AppListItem. Obviously, when the AppList object is NOT evicted and I Load/Get a particular AppListItem object it is loaded out of session rather than querying the database. The AppListItem then contains the populated bag of Attributes.
Code:
<class name="AppList, ApplicationLists" table="List">
<id name="Name" column="ListName">
<generator class="assigned"/>
</id>
<bag name="Items" table="ListItem" order-by="ItemIndex" inverse="true" cascade="all">
<key column="ListName"/>
<one-to-many class="AppListItem, ApplicationLists"/>
</bag>
</class>
<class name="AppListItem, ApplicationLists" table="ListItem">
<composite-id name="Identity" class="ItemIdentifier, ApplicationLists">
<key-many-to-one name="Parent" class="AppList, ApplicationLists" column="ListName"/>
<key-property name="Value" column="ItemId"/>
</composite-id>
<bag name="Attributes" table="ListItemAttribute" cascade="all" order-by="AttributeItemId">
<key>
<column name="ListName"/>
<column name="ListItemId"/>
</key>
<many-to-many class="AttributeItem, ApplicationLists">
<column name="AttributeName"/>
<column name="AttributeItemId"/>
</many-to-many>
</bag>
</class>
<class name="AttributeItem, ApplicationLists" table="AttributeItem">
<composite-id name="Identity" class="ItemIdentifier, ApplicationLists">
<key-many-to-one name="Parent" class="Attribute, ApplicationLists" column="AttributeName" />
<key-property name="Value" column="ItemId"/>
</composite-id>
<property name="Name" column="ItemName" unique="true"/>
<property name="SupplementalData" column="SupplementalData"/>
</class>
Findings:
I have looked at the sql statements generated when trying to load the ListItem, and everything looks fine. I've gone over the mapping properties up and down, and can not find any problems with it. I've been over the hibernate_refernece as well as the nhibernate documentation and haven't found anything that I'm doing wrong. Any help is is greatly appreciated.
Thanks,
njones