title: NHibernate one-to-many mapping problem
body: <p>I have to map two simple table with a foreign key relationship. One of the tables is <strong>Contact</strong> containing columns <strong>id</strong> (primary key of type int),<strong>name</strong>, <strong>address</strong> and <strong>guid</strong> (newly added and is not the primary key). The other one is <strong>phone__number</strong> containing columns <strong>id</strong> (primary key of type int), <strong>contact___id</strong> (foreign key of id in contact table) and <strong>phone__number</strong>.</p>
  
  <p>The mapping file for Contact table is as below :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="OfflineDbSyncWithNHibernate" default-lazy="true" namespace="OfflineDbSyncWithNHibernate.Models"&gt;
    &lt;class name="Contact" table="Contact"&gt;
      &lt;id name="Id" column="Id" type="int"&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
  
      &lt;property name="Name" column="name" type="string"/&gt;
      &lt;property name="Address" column="address" type="string"/&gt;
      &lt;property name="Guid" column="guid" type="string"/&gt;
  
      &lt;set lazy="true" batch-size="6" table="phone_number" name="PhoneNumbers" fetch="join" inverse="false" cascade="all" &gt;
        &lt;key foreign-key="FK_contact_phone_number" column="contact_id"/&gt;
        &lt;one-to-many class="PhoneNumber" /&gt;
      &lt;/set&gt;
  
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>The mapping file for Phone_number table is :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="OfflineDbSyncWithNHibernate" default-lazy="true" namespace="OfflineDbSyncWithNHibernate.Models"&gt;
    &lt;class name="PhoneNumber" table="phone_number"&gt;
      &lt;id name="Id" column="Id" type="int"&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;property name="ContactId" column="contact_id" /&gt;
      &lt;property name="Number" column="phone_number" /&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>The Contact and PhoneNumber classes are :</p>
  
  <pre><code>namespace OfflineDbSyncWithNHibernate.Models
  {
      public class Contact
      {
          public virtual int Id { get; set; }
          public virtual string Name { get; set; }
          public virtual string Address { get; set; }
          public virtual string Guid { get; set; }
          public virtual PhoneNumbers PhoneNumbers { get; set; }
      }
  }
  
  namespace OfflineDbSyncWithNHibernate.Models
  {
      public class PhoneNumber
      {
          public virtual int Id { get; set; }
          public virtual int ContactId { get; set; }
          public virtual string Number { get; set; }
      }
  }
  
  namespace OfflineDbSyncWithNHibernate.Models
  {
      public class PhoneNumbers : List&lt;PhoneNumber&gt;
      {
      }
  }
  </code></pre>
  
  <p>When I load the contact and phone_numbers separately it works, but after adding the set element to get a one-to-many relationship nhibernate is giving an error : </p>
  
  <p>NHibernate.MappingException: Invalid mapping information specified for type OfflineDbSyncWithNHibernate.Models.Contact, check your mapping file for property type mismatches</p>
  
  <p>I am new to nHibernate so I am not sure if there is a mistake in the set element or I should not even be using it. Any help will be appreciated.</p>