make PublicationID the PK. make ID a clustered index if you like. the thing is, inheritance is not just a word, it has a meaning. so, if Publication with ID=3 is of type Form, then the IDENTITY of the instance is 3. so, you must use the same PK for the base and derived tables, at least as far as NH is concerned. so you might even keep the exact same DM schema, just tell NH the PublicationId is the JoinedKey of Form.
On Tue, Sep 23, 2008 at 10:59 PM, Scott <[EMAIL PROTECTED]> wrote: > > I'm having difficulty trying to create a table-per-subclass > inheritance strategy using joined-subclass but leverage the primary > key of my child table rather than the base table. > > I have two tables... Form (child table) and Publication (base table) > and they have the following schema (only including relevant columns > for simplicity): > > Publication: > + ID : bigint PK > > Form > + ID : bigint PK > + PublicationID bigint FK > > As you can see, while it is a one-to-one from Form to Publication > where Form.PublicationID = Publication.ID, Publication.ID does NOT > equal Form.ID as Form.ID is an identity column. > > If I do a FormRepository.GetById(2) in my C# code, the SQL that > NHibernate generates is as such and not the desirable WHERE clause: > > SELECT * FROM Form f inner join Publication p ON f.PublicationID = > p.ID WHERE f.PublicationID = 2; > > What I would like it to be is > > SELECT * FROM Form f inner join Publication p ON f.PublicationID = > p.ID WHERE f.ID = 2; > > As I'm not deeply experienced in NHibernate, I was wondering if > someone knew of a solution for this or provide any insight into why > I'm experiencing this. > > Thanks in advance! > > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
