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]