Germán, thanks for the advice. I ran into that solution when I first started the design but I was hoping I could take a more object oriented approach. Based upon my results it looks like using a one-to-one is probably going to be the way I'll have to go.
Thanks again ________________________________ From: Germán Schuager <[email protected]> To: [email protected] Sent: Tue, November 24, 2009 9:18:51 AM Subject: Re: [nhusers] joined-subclass persitence I think that a one-to-one mapping with cascade="save-update" might work. http://nhforge.org/doc/nh/en/index.html#mapping-declaration-onetoone On Tue, Nov 24, 2009 at 12:11 PM, Dan <[email protected]> wrote: Within our system we have the concept of an employee. It contains your >basic employee data such as name, address, etc. We are in the process >of building a new application that needs this core employee data but >also needs to track information about a driver. Because a driver has >the same characteristics as an employee we are building this using the >joined-subclass functionality in NHibernate. The employee is the >"base" class, and the driver inherits from it, plus it has a few extra >properties. > >Tables: >Employee > Name, Address, etc >Driver > Drivers license number, etc.... > >I'm finding that if a record has been persisted through the employee, >there isn't a way to load that employee a driver. Which makes sense >because a driver record with the employee's primary key was not >created. The reason that this is needed is due to the fact that we >have a set of "core" tables that are shared across many of our >applications. In this case that table is Employee. Depending upon what >application you're working with the context changes. Some applications >you're managing employees, and in another you're managing drivers. > >So here is my question. Without writing some hack to insert a driver >record in the database; Is there a way that I can load an employee in >the context of a driver and have NHibernate understand that once it is >persisted the employee record is an update, and the driver record >would be an insert if it is the first time opening it in the driver >context? Else, it is just an update to both tables. > >Thanks, > Dan > >-- > >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. -- 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.
