title: Index was outside the bounds of the array - NHibernate 3.2
body: <p>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.</p>
  
  <p>The exception type &amp; 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.</p>
  
  <p>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.</p>
  
  <p>Nothing in the code has changed just my FNH and NH references.</p>
  
  <p>Below is my query in C#...</p>
  
  <pre><code>return ResourceRepository.Query()
                          .LeftOuterJoin(r =&gt; r.ResourceCorpus, () =&gt; resourceCorpusAlias)
                          .LeftOuterJoin(r =&gt; r.ResourceType, () =&gt; resourceTypeAlias)
                          .Cachable()
                          .List();
  </code></pre>
  
  <p>and below is the mapping hbm generated by FNH which hasnt changed between versions...</p>
  
  <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="false"&gt;
    &lt;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`"&gt;
      &lt;cache usage="read-only" /&gt;
      &lt;id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" unsaved-value="0"&gt;
        &lt;column name="Id" /&gt;
        &lt;generator class="assigned" /&gt;
      &lt;/id&gt;
      &lt;bag name="ResourceCorpus" mutable="false"&gt;
        &lt;cache usage="read-only" /&gt;
        &lt;key&gt;
          &lt;column name="ResourceId" /&gt;
        &lt;/key&gt;
        &lt;one-to-many class="MyAssembly.Reference.ResourceCorpus, MyAssembly.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
      &lt;/bag&gt;
      &lt;property name="TokenName" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt;
        &lt;column name="TokenName" /&gt;
      &lt;/property&gt;
      &lt;property name="Description" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt;
        &lt;column name="Description" /&gt;
      &lt;/property&gt;
      &lt;many-to-one class="MyAssembly.Reference.ResourceType, MyAssembly.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" fetch="select" name="ResourceType"&gt;
        &lt;column name="ResourceTypeId" /&gt;
      &lt;/many-to-one&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>In the NH 3.2 source the following line is where the exception is thrown...</p>
  
  <pre><code>if (nonCacheable != null &amp;&amp; nonCacheable[i])
  </code></pre>
  
  <p>and the call stack...</p>
  
  <pre><code>&gt;   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&lt;string&gt; 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&lt;MyAssembly.Reference.Resource&gt;()
  </code></pre>
  
  <p>So any help would be greatly appreciated, if you want any more information let me know, thanks.</p>