title: Lazy loading not working for many-to-one relationship when mapping to a non-key field using property-ref
body: <p>I have a legacy database that I am mapping using NHibernate. The objects of concern are an Account and a list of Notification objects. The objects look like: </p>
  
  <pre><code>public class Notification
  {
      public virtual int Id { get; set; }
      public virtual DateTime BatchDate { get; set; }
      /* other properties */
  
      public virtual Account Account { get; set; }
  }
  
  public class Account 
  {
      public virtual int Id { get; set; }
      public virtual string AccountNumber { get; set; }
      /* other properties */ 
  }
  </code></pre>
  
  <p>The mapping files look like:</p>
  
  <pre><code>&lt;class name="Account" table="Account" dynamic-update="true"&gt;
  &lt;id name="Id" column="AccountID"&gt;
      &lt;generator class="native" /&gt;
  &lt;/id&gt;
  &lt;property name="AccountNumber" length="15" not-null="true" /&gt;
      &lt;!-- other properties --&gt;
  &lt;/class&gt;
  
  &lt;class name="Notification" table="Notification"&gt;
      &lt;id name="Id" column="Id"&gt;
          &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;!-- other properties --&gt;
      &lt;many-to-one name="Account" class="Account" property-ref="AccountNumber" lazy="proxy"&gt;
          &lt;column name="AcctNum" /&gt;
      &lt;/many-to-one&gt;
  </code></pre>
  
  <p>However, when I create a criteria such as </p>
  
  <pre><code>return session.CreateCriteria(typeof(Notification)).List&lt;Notification&gt;();
  </code></pre>
  
  <p>I am getting a Select N+1 case where each account is loaded even though the Account is never referenced. Why are all of the accounts getting loaded when the many-to-one is mapped as a lazy proxy?</p>