-->
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: outer-join="true",cache expired, cause exception
PostPosted: Thu Sep 15, 2005 9:39 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
I am not sure if it is a bug. If I use "auto" for outer-join, it will working fine. Shall I never use outer-join="true" if I use Lazy loading for collection relationship?

Here is the decription of the phenomenon
------------------------------------------
Use the cache: NHibernate.Caches.SysCache,

Then, have this maping:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="Security" table="SECURITIES">
      <jcs-cache usage="read-write"/>
      <id name="Code" column="Code" type="AnsiString"  length="30">
         <generator class="assigned"/>
      </id>
      <bag name="ExchangeSecurityMaps" table="EXCHANGE_SECURITIES" lazy="true" access="field" outer-join="true">
         <jcs-cache usage="read-write" />
         <key column ="SEC_CODE" />
         <one-to-many class="ExchangeSecurity"/>
      </bag>
   </class>
</hibernate-mapping>

ExchangeSecurity is a class with id is Int32.
-----------------------------
1. I load the object "Security" first, which has no "ExchangeSecurity"; then wait for the cache to be expired.
2. Then I try to load a "Price" object, which has <many-to-one> association to Security, in a new session created by same sessFac. This cause the Security get reload in the new session.
3. Exception got thrown.

I trace down to line 250 of Loader.cs

Code:
if ( Owners != null )
         {
            RegisterNonExists( keys, Owners, Persisters, session );
         }

The parameter "keys" item has a empty value: keys[1] = null, cause item 1 is mapped to "ExchangeSecurity", which load nothing. keys[0] mapped to "Security" class

The strange thing is parameter "Owners" contains a item with value 0, Owners[1] = 0, which cause the method RegisterNonExists() to try to assign a Persisters[0]'s class' id, which is a string to "ExchangeSecurity"' as the id, which is a number, then exception get thrown from Key.cs, line 28.

I hope the situation described is understoodable. Please enlighten me why this is happening. Shall I always using outer-join = "auto" with lazy collection relationship? Or just because I am using caching?

Thanks
[/code]


Top
 Profile  
 
 Post subject: I got the idea
PostPosted: Thu Sep 22, 2005 9:12 am 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
anyways, lazy & outer-join is two setting contradict with each other. I should not use them together.

Please ignore this tread.


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.