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 7608147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:50:38+00:00 2026-05-31T00:50:38+00:00

I have a class mapped with NHibernate and I’m trying to use a custom

  • 0

I have a class mapped with NHibernate and I’m trying to use a custom sql-query for loading. Special thing is that it uses a composite-id but I would expect that that’s not a problem here.

Here’s a simplified version of the mapping:

<class name="Person" mutable="false">
  <composite-id>
    <key-property name="PropertyA" column="propA" type="int" />
    <key-property name="PropertyB" column="propB" type="string" />
  </composite-id>
  <property name="PropertyC" column="propC" type="datetime" />
  <loader query-ref="loadPersons" />
</class>
<sql-query name="loadPersons">
   <return class="PV" />
   <![CDATA[
   SELECT propA, propB, propC FROM MyPersons
   ]]>
</sql-query>

The problem is that the loader is completely ignored. The query sent to the database is completely generated as if the <loader> element would not be there:

SELECT this_.propA, this_.propB, this_.propC FROM Person this_

This obviously results in the error: table or view does not exist (because ‘Person’ is just our clean name).

Anyone knows if this is related to the composite-id or is there another reason why loader would be ignored?

Please note that there may be an error in returning the data as well. I’ve seen there’s a special alias-syntax for that but I can’t figure that out before the loader is actually doing something…

  • 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-31T00:50:39+00:00Added an answer on May 31, 2026 at 12:50 am

    I know this is a very old question, but I was looking for the answer and came up with something. You use a query, wrapped in parentheses, as the table. It’s a little ugly, but it works for me:

    <class name="Person" mutable="false" table="(SELECT propA, propB, propC FROM MyPersons)">
      <composite-id>
        <key-property name="PropertyA" column="propA" type="int" />
        <key-property name="PropertyB" column="propB" type="string" />
      </composite-id>
      <property name="PropertyC" column="propC" type="datetime" />
    </class>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that is mapped in fluent nhibernate but I want one
I have a class that is mapped to a table using NHibernate. The problem
I have a problem trying the following with nHibernate: Eager loading. Use selects (here
I have a class 'Company' that is being mapped using NHibernate and cached in
Suppose I have a class Customer that is mapped to the database and everything
I have a class that contains a collection that is mapped to a many-to-many
I have an entity mapped in NHibernate with optimistic concurrency control using a SQL
Here is a simplified class that can be mapped using NHibernate; public class Template
I have a model class with many properties that is mapped to the database
I have an entity that is mapped with a <join> element like this: <class

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.