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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:48:05+00:00 2026-05-11T06:48:05+00:00

Never asked a question here before, I’ll try to lay this out as succinctly

  • 0

Never asked a question here before, I’ll try to lay this out as succinctly as possible.

I’ve got a Recipe class, that contains lists of three different types of Ingredient Uses. These classes all inherit from the base, IngredientUse. So the mapping looks like this:

  <class name='IngredientUse' table='IngredientUses'>     <id name='Id' type='Int64' column='Id'>       <generator class='native'/>     </id>     <!--some other properties-->     <property name='RecipeId' column='RecipeId'/>     <joined-subclass name='AdditionUse' table='AdditionUses'>       <key column='Id' foreign-key='FK_AdditionUses_IngredientUses'/>       <many-to-one name='AdditionUsed' column='AdditionUsed' class='Addition' foreign-key='FK_AdditionUses_Additions'/>     </joined-subclass>   </class> 

The one causing problems here is the RecipeId. From the recipe, I have three separate lists of uses for different ingredient types, defined like so:

<bag name='AdditionsUsed' cascade='all' lazy='false'>   <key column='RecipeId'/>   <one-to-many class='AdditionUse'/> </bag> 

Now, I’m running into problems trying to load these lists. It has something to do with the inheritance. When I look at the SQL Generated, I see this:

SELECT additionsused0_.RecipeId as RecipeId1_ --other columns not really important FROM AdditionUses additionsused0_  inner join IngredientUses additionsused0_1_  on additionsused0_.Id=additionsused0_1_.Id  WHERE additionsused0_.RecipeId=@p0; @p0 = '11' 

Notice that its’ looking for the RecipeId in the subclass’ table, and not the base table where the column is actually contained. I know I could just define a separate table for each ingredient type, but that will cause me problems because there are some situations (ie pricing) where I don’t need the additional columns in the subclass table, and would like to be able to load all the ingredients into the same list at once.

I’m certain I must be missing something here, figured someone more familiar with NHibernate on this site might recognize it right off the bat.

Thanks in advance.

edit: in case I wasn’t clear about what I’m trying to do, this diagram might help (excuse my shoddy UML, hope it doesn’t muddy the waters). There is also an Ingredient base class, and the same subtypes off of that.

diagram

  • 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. 2026-05-11T06:48:06+00:00Added an answer on May 11, 2026 at 6:48 am

    That’s the expected behavior, the key tag is the name of the column in the ‘many’ side that references to the ‘one’…

    Create the tables in a paper, and you’ll see that if you want that your ingredient has many additions, you will need add a column in the additions table.

    By the way, never map your ids directly, map the entity instead using a many-to-one

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Right clicking on the specific report to deploy and choosing… May 12, 2026 at 12:52 am
  • Editorial Team
    Editorial Team added an answer You can use SUMIF: =SUMIF(A1:E1,"<="&TODAY(),A2:E2) Assuming your dates are in… May 12, 2026 at 12:52 am
  • Editorial Team
    Editorial Team added an answer Well, it turns out all the table names are prefixed… May 12, 2026 at 12:52 am

Related Questions

Never asked a question here before, I'll try to lay this out as succinctly
Here is how our Tomcat webserver is currently setup. We are using jsp for
As a result of another question I asked here I want to use a
I asked something similar to this before and never got an answer, here's a
I thought this question would have been asked before, but I couldn't find it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.