I've been trying to upgrade a project using fluent nhibernate 1.2 and NHibernate 3.1 to FNH 1.3 and NH 3.2, and it all seems to work except now Im getting an exception on a .List() command.
The exception type & message are... NHibernate.Exceptions.GenericADOException Unable to perform find[SQL: SQL not available] and the inner exception... System.IndexOutOfRangeException Index was outside the bounds of the array.
I have profiled the query in SQL Server and I think its a problem with the AppFabric cache and NH 3.2 because the query generated by NH is fine.
Nothing in the code has changed just my FNH and NH references.
Below is my query in C#...
return ResourceRepository.Query()
.LeftOuterJoin(r => r.ResourceCorpus, () => resourceCorpusAlias)
.LeftOuterJoin(r => r.ResourceType, () => resourceTypeAlias)
.Cachable()
.List();
and below is the mapping hbm generated by FNH which hasnt changed between versions...
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="false">
<class xmlns="urn:nhibernate-mapping-2.2" schema="[Reference]" mutable="false" name="MyAssembly.Reference.Resource, MyAssembly.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`Resource`">
<cache usage="read-only" />
<id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" unsaved-value="0">
<column name="Id" />
<generator class="assigned" />
</id>
<bag name="ResourceCorpus" mutable="false">
<cache usage="read-only" />
<key>
<column name="ResourceId" />
</key>
<one-to-many class="MyAssembly.Reference.ResourceCorpus, MyAssembly.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
<property name="TokenName" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="TokenName" />
</property>
<property name="Description" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Description" />
</property>
<many-to-one class="MyAssembly.Reference.ResourceType, MyAssembly.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" fetch="select" name="ResourceType">
<column name="ResourceTypeId" />
</many-to-one>
</class>
</hibernate-mapping>
In the NH 3.2 source the following line is where the exception is thrown...
if (nonCacheable != null && nonCacheable[i])
and the call stack...
> NHibernate.dll!NHibernate.Type.TypeHelper.Disassemble(object[] row, NHibernate.Type.ICacheAssembler[] types, bool[] nonCacheable, NHibernate.Engine.ISessionImplementor session, object owner)
NHibernate.dll!NHibernate.Cache.StandardQueryCache.Put(NHibernate.Cache.QueryKey key, NHibernate.Type.ICacheAssembler[] returnTypes, System.Collections.IList result, bool isNaturalKeyLookup, NHibernate.Engine.ISessionImplementor session)
NHibernate.dll!NHibernate.Loader.Loader.PutResultInQueryCache(NHibernate.Engine.ISessionImplementor session, NHibernate.Engine.QueryParameters queryParameters, NHibernate.Type.IType[] resultTypes, NHibernate.Cache.IQueryCache queryCache, NHibernate.Cache.QueryKey key, System.Collections.IList result)
NHibernate.dll!NHibernate.Loader.Loader.ListUsingQueryCache(NHibernate.Engine.ISessionImplementor session, NHibernate.Engine.QueryParameters queryParameters, Iesi.Collections.Generic.ISet<string> querySpaces, NHibernate.Type.IType[] resultTypes)
NHibernate.dll!NHibernate.Loader.Criteria.CriteriaLoader.List(NHibernate.Engine.ISessionImplementor session)
NHibernate.dll!NHibernate.Impl.SessionImpl.List(NHibernate.Impl.CriteriaImpl criteria, System.Collections.IList results)
NHibernate.dll!NHibernate.Impl.CriteriaImpl.List(System.Collections.IList results)
NHibernate.dll!NHibernate.Impl.CriteriaImpl.List<MyAssembly.Reference.Resource>()
So any help would be greatly appreciated, if you want any more information let me know, thanks.