Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Join Mappings in NHibernate
    text
    copied!<p>First question on Stackoverflow.</p> <p>After using JOIN to map a property I try to use the property for another join from a third table. The problem is that in the generated SQL the second JOIN statement uses the correct column but from the original table and not the second table.</p> <p>Here's the mapping - </p> <pre><code> &lt;class name="Core.Domain.NetHistoryMessage, Core" table="NHistoryIN" &gt; &lt;id name="ID"&gt; &lt;column name="ID"/&gt; &lt;generator class="assigned"/&gt; &lt;/id&gt; &lt;property name="RecipientDuns" unique="true"&gt; &lt;column name="Recipient" unique="true"/&gt; &lt;/property&gt; &lt;join table="DunsSites" optional="true" fetch="select"&gt; &lt;key column="Duns" property-ref="RecipientDuns" /&gt; &lt;property name="RecipientID" column="SiteID" unique="true" lazy="false"/&gt; &lt;/join&gt; &lt;join table="Components" optional="true" &gt; &lt;key column="ComponentID" property-ref="RecipientID" /&gt; &lt;property name="RecipientName" column="ComponentName" unique="true" lazy="false"/&gt; &lt;/join&gt; </code></pre> <p></p> <p>The generated SQL - </p> <pre><code>SELECT this_.*, this_1_.SiteID as SiteID7_0_, this_2_.M_SNAME as M3_11_0_ FROM RNTransactionHistoryIN this_ left outer join DunsSites this_1_ on this_.Recipient=this_1_.Duns left outer join Components this_2_ on this_.SiteID=this_2_.ComponentID </code></pre> <p>I need the following SQL - </p> <pre><code>SELECT this_.*, this_1_.SiteID as SiteID7_0_, this_2_.M_SNAME as M3_11_0_ FROM RNTransactionHistoryIN this_ left outer join DunsSites this_1_ on this_.Recipient=this_1_.Duns left outer join Components this_2_ on this_1_.SiteID=this_2_.ComponentID </code></pre> <p>I'm using NHibbernate 3.2.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload