|
I have a table called Patient. Two objects are written to Patient, they are Patient and PatientDemographics, which have their own classes Patient.java and PatientDemographics.java. There is a uni-directional reference from Patient to PatientDemographics called demographics, so I model this as follows in my mapping Patient.hbm.xml, which I believe is correct.
<class name="com.orchestral.cdr.element.Patient">
...
...
<component name="demographics" class="com.orchestral.cdr.element.PatientDemographics">
<property name="livingDependency"/>
<property name="livingArrangement"/>
<one-to-one
name="publicityCode"
class="com.orchestral.cdr.element.PatientPublicityCode"
cascade="all">
</one-to-one>
</component>
...
...
</class>
There is a bi-directional reference called publicity in PatientDemographics called PatientPublicityCode, and that information is stored in the PatientPublicityCode table. I put a one-to-one relationship in my mapping as above. This is currently my mapping in PatientPublicityCode.hbm.xml, which is probably incorrect.
<class name="com.orchestral.cdr.element.PatientPublicityCode" table="PatPublicityCode">
<many-to-one
name="patientDemographics"
class="com.orchestral.cdr.element.PatientDemographics"
column="patientFK">
</many-to-one>
My question is how does PatientPublicityCode refer back to PatientDemographics component??? Hibernate complains that PatientDemographics does not have a mapping file and I don't want to create a new mapping file for this. In my PatientPublicity class I have a reference back to patientDemographics, but I would like to refer back to that component portion in Patient.hbm.xml
Any assistance is appreciated.
[b]Hibernate version:2.1.6[/b]
[b]Mapping documents:[/b]
[b]Code between sessionFactory.openSession() and session.close():[/b]
[b]Full stack trace of any exception that occurs:[/b]
[b]Name and version of the database you are using:[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:[/b]
|