title: How do I get NHibernate to return data on composite key table?
body: <p>I have a junction table in my database. I need to read the id values and use them in my program. I cannot get NHibernate to return any records in the database. It appears as though my mapping file "compiles", but no results are returned.</p>
  
  <p><strong>LinkTable</strong></p>
  
  <ul>
  <li><strong>int</strong> id_ObjectA <em>(foreign key)</em></li>
  <li><strong>int</strong> id_ObjectB <em>(foreign key)</em></li>
  </ul>
  
  <p><strong>LinkDAO Class:</strong></p>
  
  <pre><code>public class LinkDAO
  {
      public virtual ObjectADAO ObjectA { get; set; }
      public virtual ObjectBDAO ObjectB { get; set; }
  
      public override bool Equals(object obj)
      {
          if (obj == null)
          {
              return false;
          }
          var t = obj as LinkDAO;
          if (t == null)
          {
              return false;
          }
          return (t.ObjectA == ObjectA &amp;&amp; t.ObjectB == ObjectB);
      }
  
      public override int GetHashCode()
      {
          return (ObjectA.Name + "|" + ObjectB.Name).GetHashCode();
      }
  }
  </code></pre>
  
  <p><em><strong>Mapping File</strong> 'LinkDAO.hbm.xml':</em></p>
  
  <pre><code>&lt;class name="LinkDAO" table="LinkTable" lazy="false"&gt;
      &lt;composite-id&gt;
        &lt;key-property name="ObjectA" column="id_ObjectA" /&gt;
        &lt;key-property name="ObjectB" column="id_ObjectB" /&gt;
      &lt;/composite-id&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>I'm querying like this:</p>
  
  <pre><code>IList&lt;LinkDAO&gt; links  =
          NHibernateContext.Current().Session.QueryOver&lt;LinkDAO&gt;().List();
  //Empty list is returned, but I can check the DB and see records 
  </code></pre>
  
  <p><strong>Question:</strong>
  How do I read the two columns as int values when the table is comprised of only a composite key? (Having references to the actual object would be useful, but the int ids are sufficient)</p>