Hello,
I am running into a problem after upgrading from 2.0 to 2.1.2. A mapped entity called ResearchItem has a bag of ResearchItemDatum; the property is called Data. The relationship is bi-directional - ResearchItemDatum is associated back to ResearchItem; the property is called Item. When I load a ResearchItem by id, and access the Data property, I'm expecting that collection to get initialized, exactly as it has worked for years in NH 2.0 and below. However, after upgrading to 2.1.2, the bag is initialized, but remains empty. I've included the relevant mapping xml.
Has anyone seen this symptom, or can point me in the right direction? I saw just one post about this issue after extensive Googling - and Fabio instructed that user to update NH to the 2.1.2GA release, but that is the one I'm already using.
Code:
<class name="ResearchItem"
table="ResearchItem">
...
<discriminator column="researchItemType" type="String" />
<version name="ModificationVersion" column="modificationVersion" access="nosetter.camelcase" />
<property name="Name" column="name" />
<bag name="Data" cascade="all-delete-orphan" inverse="true">
<key column="itemID" />
<one-to-many class="ResearchItemDatum" />
</bag>
...
</class>
<class name="ResearchItemDatum"
table="ResearchItemDatum" batch-size="10">
...
<discriminator column="researchItemDatumType" type="String" />
<property name="Name" column="name" />
<many-to-one name="Item" column="itemID" cascade="save-update" />
...
</class>
Here is a snippet of the debug-level log generated by the NH framework when the bag is accessed and initialized. Note the mention of "2 collections initialized for role" of Data. I'm not sure if this is normal. BTW, this is happening when debugging the project in VS2008 - not sure if the new feature of dynamically loading the proxy factory DLL is complicating things.
Code:
2010-02-02 18:48:51,107 [11] DEBUG NHibernate.Engine.Loading.LoadContexts [(null)] <(null)> - attempting to locate loading collection entry [CollectionKey[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6C59F72A-2443-43D4-B0A4-94123E3A4456]] in any result-set context
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.LoadContexts [(null)] <(null)> - collection [CollectionKey[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6C59F72A-2443-43D4-B0A4-94123E3A4456]] not located in load context
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - removing collection load entry [NHibernate.Engine.Loading.LoadingCollectionEntry<rs=NHibernate.Driver.NHybridDataReader, coll=[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6C59F72A-2443-43D4-B0A4-94123E3A4456]>@d4fc32]
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.LoadContexts [(null)] <(null)> - attempting to locate loading collection entry [CollectionKey[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6c59f72a-2443-43d4-b0a4-94123e3a4456]] in any result-set context
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.LoadContexts [(null)] <(null)> - collection [CollectionKey[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6c59f72a-2443-43d4-b0a4-94123e3a4456]] not located in load context
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - removing collection load entry [NHibernate.Engine.Loading.LoadingCollectionEntry<rs=NHibernate.Driver.NHybridDataReader, coll=[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6c59f72a-2443-43d4-b0a4-94123e3a4456]>@c445a9]
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - 2 collections were found in result set for role: DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - ending loading collection [NHibernate.Engine.Loading.LoadingCollectionEntry<rs=NHibernate.Driver.NHybridDataReader, coll=[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6C59F72A-2443-43D4-B0A4-94123E3A4456]>@d4fc32]
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - collection fully initialized: [DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6C59F72A-2443-43D4-B0A4-94123E3A4456]
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - ending loading collection [NHibernate.Engine.Loading.LoadingCollectionEntry<rs=NHibernate.Driver.NHybridDataReader, coll=[DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6c59f72a-2443-43d4-b0a4-94123e3a4456]>@c445a9]
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - collection fully initialized: [DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data#6c59f72a-2443-43d4-b0a4-94123e3a4456]
2010-02-02 18:48:51,108 [11] DEBUG NHibernate.Engine.Loading.CollectionLoadContext [(null)] <(null)> - 2 collections initialized for role: DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data
Thanks very much for reading.
-Sasha Borodin