title: why doesn't NHibernate FetchMode.Join work in this scenario?
body: <p>I have two entities, C and P.
  C is mapped to P in a one-to-one association, with lazy="no-proxy",
  like this: (P's mapping:)</p>
  
  <pre><code>&lt;one-to-one name="c" class="C" property-ref="P" access="field" lazy="no-proxy"/&gt;
  </code></pre>
  
  <p>P is mapped to C in a many-to-one association, like this: (C's mapping:)</p>
  
  <pre><code>&lt;many-to-one name="p" column="PId" class="P" access="field" lazy="no-proxy" not-null="false"/&gt;
  </code></pre>
  
  <p>usually I use lazy fetching, but in some cases I use FetchMode.Join to avoid the N+1 SELECTs problem, like this:</p>
  
  <pre><code>criteria.SetFetchMode("p", FetchMode.Join)
  </code></pre>
  
  <p>however, using FetchMode.Join for the C entity performs the query with a left outer join, and then immediately performs N more queries, fetching P's by ID! (profiling courtesy of NHProf)</p>
  
  <p>any idea why this is happening?</p>
  
  <hr>
  
  <p>answering @KLE's question, here's an excerpt from the documentation <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-manytoone" rel="nofollow noreferrer">here</a></p>
  
  <blockquote>
    <p>For a primary key association, add
    the following mappings to Employee and
    Person respectively:</p>
  </blockquote>
  
  <pre><code>&lt;one-to-one name="person" class="Person"/&gt;
  &lt;one-to-one name="employee" class="Employee" constrained="true"/&gt;
  </code></pre>
  
  <blockquote>
    <p>Ensure that the primary keys of the related rows in the PERSON and EMPLOYEE tables are equal. 
     Alternatively, a foreign key with a
    unique constraint, from Employee to
    Person, can be expressed as:</p>
  </blockquote>
  
  <pre><code>&lt;many-to-one name="person" class="Person" column="PERSON_ID" &gt; unique="true"/&gt;
  </code></pre>
  
  <blockquote>
    <p>This association can be made
    bidirectional by adding the following
    to the Person mapping:</p>
  </blockquote>
  
  <pre><code>&lt;one-to-one name="employee" class="Employee" property-ref="person"/&gt;
  </code></pre>
  
  <p>please let me know if I misunderstood this. thanks.</p>