In your explanation you are mixing 'class' with tables. Can we see the implementation of your domain ? I would see if the relation is bidirectional or not and where is declared the property. Where the relation is not bidirectional the Person FK, and using table-per-class, should be in the table representing the class related with Person.
-- Fabio Maulo El 11/11/2010, a las 10:23, Ron Denis <[email protected]> escribió: The problem is that the query that is created when the Person.Races collection is lazy loaded is incorrect. Nhibernate is generating SQL that joins Person.PersonKey to Race.PersonKey; however Race doesn’t have a PersonKey. Race inherits from Attribute and Attribute has a PersonKey. I imagine that I am doing something wrong when I build the mapping information because somehow Nhibernate is expecting Race to have a PersonKey when my intent is that Race inherits PersonKey from Attribute. Regards, Ron *From:* [email protected] [mailto:[email protected]] *On Behalf Of *Fabio Maulo *Sent:* Tuesday, November 09, 2010 12:20 PM *To:* [email protected] *Subject:* Re: [nhusers] Problems with a bag of joined subclass entities I didn't understand the problem. On Tue, Nov 9, 2010 at 10:56 AM, Ron Denis <[email protected]> wrote: Good morning. I am still struggling to find a solution to this. Does anyone have any suggestions? Regards, Ron -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of rdenis Sent: Thursday, November 04, 2010 10:30 AM To: nhusers Subject: [nhusers] Problems with a bag of joined subclass entities Guys, As the title says, i have a mapping issue. I have tried to condense the issue into a contrived example as follows. I have: 1) A Person entity with a PersonKey primary key. 2) An Attribute entity with a reference to Person (has a PersonKey foreign key). 3) A Race entity that is a joined subclass of the Attribute entity. 4) The Person entity has an IList of Race entities (a Races property). The problem is that nhibernate doesn't seem to recognize that Race will inherit the PersonKey from Attribute. In the sql generation it wants to add a PersonKey column to Race. Also, when I access the Races property of Person, the lazy load mechanism kicks in tries to query the list of Race entities by accessing Race.PersonKey, which, again should come from the Attribute class. Any help would be greatly appreciated. ------------------------------ Additional Information: The Person mapping: <class name="Person" table="Person"> <id name="Key" .... <column name="PersonKey" /> ... </id> <bag inverse="true" name="IntoleranceConditions"> <key> <column name="PersonKey" /> </key> <one-to-many class="Race" /> </bag> </class> The Attribute and Race Mappings: <class name="Attribute" table="Attribute"> <id name="Key" ... <column name="AttributeKey" /> ... </id> <joined-subclass name="Race"> <key foreign-key="Foo_FK"> <column name="AttributeKey" /> </key> </joined-subclass> </class> -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]<nhusers%[email protected]> . For more options, visit this group at http://groups.google.com/group/nhusers?hl=en. ________________________________ The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]<nhusers%[email protected]> . For more options, visit this group at http://groups.google.com/group/nhusers?hl=en. -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en. ------------------------------ The contents of this e-mail and any attachments are intended solely for the use of the named addressee(s) and may contain confidential and/or privileged information. Any unauthorized use, copying, disclosure, or distribution of the contents of this e-mail is strictly prohibited by the sender and may be unlawful. If you are not the intended recipient, please notify the sender immediately and delete this e-mail. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
