Nhibernate:null index column for collection Error

Posted by Quintin Par on Stack Overflow See other posts from Stack Overflow or by Quintin Par
Published on 2010-03-25T07:35:20Z Indexed on 2010/03/25 7:43 UTC
Read the original article Hit count: 219

I am working a subsonic to NH migration(I can’t change the schema) and while creating the mapping I came across this error

null index column for collection: Company.Core.CompanyUser.Addresses

My mapping from the User side is

mapping.HasMany(x => x.Addresses).AsList().KeyColumn("user_id").Cascade.All().Inverse();

xml

<list cascade="all" inverse="true" name="Addresses">
  <key>
    <column name="user_id" />
  </key>
  <index />
  <one-to-many class="Company.Core.CompanyAddress, Company.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</list>

On the Address side it is

 mapping.CompositeId().KeyReference(x => x.User, "user_id").KeyProperty(x => x.Type);

xml

<composite-id mapped="false" unsaved-value="undefined">
  <key-property name="Type" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <column name="Type" />
  </key-property>
  <key-many-to-one name="User" class="Company.Core.CompanyUser, Company.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
    <column name="user_id" />
  </key-many-to-one>
</composite-id>  

When I try to load this collection as

user.Addresses

I get the index null exception.

How do I fix this error?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about fluent-nhibernate