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

  • SEARCH
  • Home
  • 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 6187551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:04:41+00:00 2026-05-24T02:04:41+00:00

I have a view joining 3 tables together in a chain that i need

  • 0

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:

SELECT tblTable1.*,tblTable2.*,tblTable3.MyProperty FROM tblTable1
OUTER JOIN
tblTable2 ON tblTable1.Table1Key = tblTable2.Table1Key
OUTER JOIN
tblTable3 ON tblTable2.Table2Key = tblTable3.Table2Key

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?

When i do the mapping like this i get a query trying to join tblTable3 on Table1Key for some reason.

<class name="MyClass" table="tblTable1">

<id name="Table1Key">
  <generator class="identity"/>
</id>

<property name="..." />

<join table="tblTable2">
  <key column="Table1Key" />

  <property name="..." />
</join>

<join table="tblTable3">
  <key column="Table2Key???" />

  <property name="..." />
</join>

</class>
  • 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-24T02:04:43+00:00Added an answer on May 24, 2026 at 2:04 am

    in NH you can’t join in a join. the only way is to make it a reference, which does basicly the same thing

    <class name="MyClass" table="tblTable1">
      <id name="Table1Key">
        <generator class="identity"/>
      </id>
    
      <property name="..." />
    
      <many-to-one table="tblTable2" lazy="false">
        <key column="Table1Key" />
    
        <property name="..." />
      </many-to-one>
    </class>
    
    <class name="MyClass2" table="tblTable2">
    
      <join table="tblTable3">
        <key column="Table2Key" />
    
        <property name="..." />
      </join>
    </class>
    
    class MyClass
    {
        public virtual MyClass2 MyClass2 { get; set; }
    
        public virtual int MyClass2_MyProperty
        {
            get { return MyClass2.MyProperty; }
            set { MyClass2.MyProperty = value; }
        }
    }
    
    class MyClass2
    {
        public virtual int MyProperty { get; set; }
    }
    

    Edit Option 2: if you dont want MyClass2 Maybe you can tweak this:

    <class name="MyClass" table="tblTable2">    <-- take table2 as the main table
      <id name="Table1Key">
        <generator class="sequence">  <-- can be problem here, use sequence (directly) instead?
          <param name="sequencename">table1_id_squence</param> // not sure about "sequencename"
        </generator>
      </id>
    
      <property name="..." />
    
      <join table="tblTable1">
        <key column="Table1Key" />
    
        <property name="..." />
      </join>
    
      <join table="tblTable3">
        <key column="Table2Key" />
    
        <property name="..." />
      </join>
    </class>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that I am trying to add to my ADO.NET Entity
I have a view controller that is used to populate data from the core
I have a view controller that i'm trying to push onto the navigation stack.
I have a view that overlays a CATiledlayer. The view is somewhere in the
Let's say I have a viewcontroller ViewBViewController. In that viewcontroller I create an instance
I have a view with a web view which loads a YouTube video. I
I have list view which contains 2 buttons and 2 textviews. I change the
I have a view with which you can do finger drawing. It's currently in
I have a web solution (in VS2010) with two sub-projects: Domain which holds the
I used nifty scaffolding for create controller 'A'. For this controller I have in

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.