title: NHibernate One-To-One Relationship
body: <p>I have the following <code>Domain Model(s)</code>:</p>
  
  <pre><code>public class WriteOffApprovalUser
  {
      public virtual string UserName { get; set; }
      public virtual Employee Employee { get; set; }
  }
  
  public class Employee
  {
      public virtual string EmployeeID { get; set; }
      public virtual string EmployeeStatusCode { get; set; }
      public virtual string FirstName { get; set; }
      public virtual string LastName { get; set; }
      public virtual string PreferredName { get; set; }
      public virtual string JobTitle { get; set; }
      public virtual string Division { get; set; }
      public virtual string Department { get; set; }
      public virtual string Location { get; set; }
      public virtual string City { get; set; }
      public virtual string DeskLocation { get; set; }
      public virtual string MailID { get; set; }
      public virtual string Phone { get; set; }
      public virtual string Fax { get; set; }
      public virtual string SecCode { get; set; }
      public virtual string UserId { get; set; }
      public virtual string SupervisorID { get; set; }
  }
  </code></pre>
  
  <p>These are my <code>Fluent Mappings</code></p>
  
  <pre><code>public class WriteOffApprovalUserMap : ClassMap&lt;WriteOffApprovalUser&gt;
  {
      public WriteOffApprovalUserMap()
      {
          //Schema("LEGAL");
          Table("WRITEOFF_APPROVAL_USER");
  
          Id(x =&gt; x.UserName).Column("USER_NAME");
  
          HasOne(x =&gt; x.Employee).PropertyRef("UserId");
  
      }
  }
  
  public class EmployeeMap : ClassMap&lt;Employee&gt;
  {
      public EmployeeMap()
      {
          // Table Name
          //Schema("ADP_FEED_OWNER");
          Table("ADP_EMPLOYEE");
  
          // Primary Key
          Id(x =&gt; x.EmployeeID).Column("EMPLID");
  
          // Mappings
          Map(x =&gt; x.UserId).Column("USER_ID");
          Map(x =&gt; x.FirstName).Column("FIRST_NAME");
          Map(x =&gt; x.LastName).Column("LAST_NAME");
          Map(x =&gt; x.PreferredName).Column("PREFERRED_NAME");
      }
  }
  </code></pre>
  
  <p>Here is my Query:</p>
  
  <pre><code>var results = new Repository&lt;WriteOffApprovalUser&gt;(session)
                      .Query()
                      .ToList();
  </code></pre>
  
  <p>This is the SQL it is generating, and I was expecting a JOIN instead.</p>
  
  <pre><code>select writeoffap0_.USER_NAME as USER1_1_ from WRITEOFF_APPROVAL_USER writeoffap0_
  SELECT employee0_.EMPLID as EMPLID0_0_, employee0_.USER_ID as USER2_0_0_, employee0_.FIRST_NAME as FIRST3_0_0_, employee0_.LAST_NAME as LAST4_0_0_, employee0_.PREFERRED_NAME as PREFERRED5_0_0_ FROM ADP_EMPLOYEE employee0_ WHERE employee0_.EMPLID=:p0;
  SELECT employee0_.EMPLID as EMPLID0_0_, employee0_.USER_ID as USER2_0_0_, employee0_.FIRST_NAME as FIRST3_0_0_, employee0_.LAST_NAME as LAST4_0_0_, employee0_.PREFERRED_NAME as PREFERRED5_0_0_ FROM ADP_EMPLOYEE employee0_ WHERE employee0_.EMPLID=:p0;
  SELECT employee0_.EMPLID as EMPLID0_0_, employee0_.USER_ID as USER2_0_0_, employee0_.FIRST_NAME as FIRST3_0_0_, employee0_.LAST_NAME as LAST4_0_0_, employee0_.PREFERRED_NAME as PREFERRED5_0_0_ FROM ADP_EMPLOYEE employee0_ WHERE employee0_.EMPLID=:p0;
  SELECT employee0_.EMPLID as EMPLID0_0_, employee0_.USER_ID as USER2_0_0_, employee0_.FIRST_NAME as FIRST3_0_0_, employee0_.LAST_NAME as LAST4_0_0_, employee0_.PREFERRED_NAME as PREFERRED5_0_0_ FROM ADP_EMPLOYEE employee0_ WHERE employee0_.EMPLID=:p0;
  </code></pre>
  
  <p>Now there are four rows in the database, and the right data is coming back, but I would not expect five separate SQL statements to do this.</p>