Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:04:31+00:00 2026-05-26T13:04:31+00:00

First question on Stackoverflow. After using JOIN to map a property I try to

  • 0

First question on Stackoverflow.

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.

Here’s the mapping –

 <class name="Core.Domain.NetHistoryMessage, Core" table="NHistoryIN" >
<id name="ID">
  <column name="ID"/>
  <generator class="assigned"/>
</id>     
<property name="RecipientDuns" unique="true">
  <column name="Recipient" unique="true"/>
</property>
<join table="DunsSites" optional="true" fetch="select">
  <key column="Duns" property-ref="RecipientDuns" />
  <property name="RecipientID" column="SiteID" unique="true" lazy="false"/>
</join>
<join table="Components"  optional="true" >
  <key column="ComponentID"   property-ref="RecipientID" />
  <property name="RecipientName" column="ComponentName" unique="true" lazy="false"/>
</join> 

The generated SQL –

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

I need the following SQL –

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

I’m using NHibbernate 3.2.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:04:31+00:00Added an answer on May 26, 2026 at 1:04 pm

    i tried the same but never got it to work. <join> is meant to only join from the original table, not cascading. better you declare DunsSite as an Entity and use <join> from there to Components. then you can introduce Convenienceproperties on NetHistoryMessage.

    public string ComponentName
    {
        get { return DunsSite.ComponentName; }
        set { DunsSite.ComponentName = value; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question to stackoverflow so here it goes... I use cruise
I found (after another question here on StackOverflow) this interesting library written in Python
First question on Stackoverflow (.Net 2.0): So I am trying to return an XML
This is my first question on stackoverflow. I just wonder why my getJSON code
This is my first StackOverflow question so be nice! :-) I recently came across
Greetings to all! This is my first question here on stackoverflow. I have a
First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
First off - hello, this is my first Stack Overflow question so I'll try
I asked same question on stackoverflow . First, here is a picture of what
this is my third question so far on stackoverflow :D i am defining files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.