views:

1105

answers:

2
+1  A: 

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

Diego Jancic
thats the thing, I don't want to map to the AdditionUse table, I want to map to the IngredientUse table, using AdditionUse as a filter and for extra info. I guess I'll need to abandon NHibernate, or rethink how my tables are set up. Thanks for the response.
AlexCuse
No, NH must work fine, you aren't working with a complex domain model. You should start over designing your objects, not your tables.Not sure if I understand all you want to do, but start removing the <property name="RecipeId"> and the changing the class in the bag to "IngredientUse".
Diego Jancic
Maybe I'm just being thick, but I don't think that will get me where I want to go. The subclasses from I.Use all have their own special data and behavior, and if I change bag type to I.Use, I lose all that. Seems like a big sacrifice to make to me, when I could easily suck it up and write the SQL.
AlexCuse
I added an image to make sure we're on the same page with regard to what I'm trying to do with the classes. I'm not 100% sold on it yet, but think it really would work well for my application (the base "IngredientUse" type is used for other things besides recipes, like pricing and scheduling)
AlexCuse
Diego, I had an idea when I was driving around today thinking about what you said, that I think will solve this problem. A little more mapping, but it'd let me eliminate one table. I will test it out when I get a chance. Thanks again!
AlexCuse
A: 

I have similar problem http://www.flickr.com/photos/32323434@N07/4289137497/

How would i accomplish an admission for a student using one table for sub-class

razorxpress