title: NHibernate: Mapping a join on a joined table
body: <p>I have a view joining 3 tables together in a chain that i need to replace with a NHibernate mapping without any changes to the database. Is this possible?
  This is a simplified example of my view:</p>
  
  <pre><code>SELECT tblTable1.*,tblTable2.*,tblTable3.MyProperty FROM tblTable1
  OUTER JOIN
  tblTable2 ON tblTable1.Table1Key = tblTable2.Table1Key
  OUTER JOIN
  tblTable3 ON tblTable2.Table2Key = tblTable3.Table2Key
  </code></pre>
  
  <p>so basicaly we select tblTable1 and join tblTable2 this works for me in NHibernate. My problem is tblTable3. How do i join it on a property from the joined table tblTable2? </p>
  
  <p>When i do the mapping like this i get a query trying to join tblTable3 on Table1Key for some reason.</p>
  
  <pre><code>&lt;class name="MyClass" table="tblTable1"&gt;
  
  &lt;id name="Table1Key"&gt;
    &lt;generator class="identity"/&gt;
  &lt;/id&gt;
  
  &lt;property name="..." /&gt;
  
  &lt;join table="tblTable2"&gt;
    &lt;key column="Table1Key" /&gt;
  
    &lt;property name="..." /&gt;
  &lt;/join&gt;
  
  &lt;join table="tblTable3"&gt;
    &lt;key column="Table2Key???" /&gt;
  
    &lt;property name="..." /&gt;
  &lt;/join&gt;
  
  &lt;/class&gt;
  </code></pre>