Thanks for the replies. I am excited to have a community to help me think about the relationships that I'm trying to model and to be able to leverage your experience.:D
First, let me respond to the issue of the OO design. My approach in the past has come from a database perspective (my experience/positions have dictated such), but, that creates issues for the non-database developers because the objects end up looking funny. I agree with
rponton's conclusion not to get rid of the Patient class. If I were an the customer (developer) to use these classes, what would I want them to look like. Forget about the database and what should the hierarchy look like and what should the classes act like? The answer is easy because I have other developers telling me what they don't want the classes to look like. So, we keep the hierarchy of Patient and Doctor inherit from Person.
This also brings us to the conclusion that there shouldn't be a PatientAndDoctor class. It's just not right logically. So, the suggestion to map it with Discriminator-value="3" is not going to work.
Sorry to shoot down those ideas, but, I think what I have come up with seems to be similar to
KPixel's suggestion about trying to use <joined-subclass> (I don't think I see how I could implement this though). So, what I have done is map the Person object as it was before. What I changed is I mapped all of the properties for a Person directly onto the Patient and Doctor classes.
Code:
<class name="Patient" where="IsPatient='T'"...>
...
<!-- Person properties -->
<property name="FirstName"...>
...
<!-- Patient properties -->
<property name="PrimaryCarePhysician"...>
</class>
The only problem with this method is that I have to explicitly map the IsPatient property and explicitly set this property in my code before saving the object out. But, now I can do queries like "from Patient" and it automatically hydrates the parent class Person. It works, but, there's got to be a better way. :?:
Is there a way to do it with the <joined-subclass> even though the entire hierarchy comes from the same table?