-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: empty bags after upgrading to 2.1.2
PostPosted: Tue Feb 02, 2010 9:25 pm 
Beginner
Beginner

Joined: Wed Jul 05, 2006 12:45 pm
Posts: 21
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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 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)] &lt;(null)&gt; - 2 collections initialized for role: DFWHC.GroupOne.GoRes.business.research.ResearchItem.Data


Thanks very much for reading.

-Sasha Borodin


Top
 Profile  
 
 Post subject: Re: empty bags after upgrading to 2.1.2
PostPosted: Wed Feb 03, 2010 4:11 pm 
Beginner
Beginner

Joined: Wed Jul 05, 2006 12:45 pm
Posts: 21
SOLVED. This had little to do with the upgrade to 2.1.2, but rather my testing code. However, a case can be made for a bug ticket as well.

The ID of the parent object was a String type in my class and mapping. In the database, the id column was a uniqueidentifier (a Guid) type. In my test code, I was loading the parent object with a String representation of a Guid - "6C59F72A-2443-43D4-B0A4-94123E3A4456". From the logs I could tell that the child objects belonging to the collection WERE in fact queried for and instantiated - and yet the collection in the parent object itself remained empty. What I have found is that switching the String Guid to all LOWERCASE resolved this phenomenon.

This leads me to believe that, while the database itself is case-insensitive when querying for rows by a Guid, something within the NH framework treats String keys in a case-SENSITIVE manner (at least in the context of initializing lazy collections). The proper solution seems to convert my objects (and mappings) to use a Guid type for my ID property (instead of a String).

If an NH developer or someone with more knowledge than myself can confirm or clearify this situation, I would really appreciate it. If the case-sensitivity should not be, I can file a JIRA ticket as well.

Thanks very much,

-Sasha Borodin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.