Ok here is the final version of the mapping that should work but does not.
Parent
Code:
<hibernate-mapping>
<class name="bus.PatientDoctorListRegSDC" table="PatientDoctorListRegSDC">
<id name="recID" type="int" unsaved-value="null" >
<column name="RECID" sql-type="int" not-null="true"/>
<generator class="native" />
</id>
<property name="acctNumber">
<column name="ACCTNUMBER"/>
</property>
<property name="URN">
<column name="URN"/>
</property>
<property name="name">
<column name="NAME"/>
</property>
<property name="status">
<column name="STATUS"/>
</property>
<property name="URN2">
<column name="URN2"/>
</property>
<property name="timeStampID">
<column name="TIMESTAMPID"/>
</property>
<many-to-one name="location" column="LOCATION" class="bus.Location" not-null="false" />
<many-to-one name="attendDoctor" column="ATTENDDOCTOR" class="bus.Provider" not-null="false" />
<many-to-one name="admitDoctor" column="ADMITDOCTOR" class="bus.Provider" not-null="false" />
<many-to-one name="familyDoctor" column="FAMILYDOCTOR" class="bus.Provider" not-null="false" />
<many-to-one name="primCareDoctor" column="PRIMCAREDOCTOR" class="bus.Provider" not-null="false" />
<many-to-one name="consultingDoctor" column="CONSULTINGDOCTOR" class="bus.Provider" not-null="false" />
<many-to-one name="otherDoctor" column="OTHERDOCTOR" class="bus.Provider" not-null="false" />
--- Here is the set -------
<set name="nurpc" inverse="true" cascade="all" order-by="timeStampID desc, MIInitDate" lazy="false">
<key>
<column name="ACCTNUMBER" not-null="true" />
<column name= "TIMESTAMPID" not-null="true" />
</key>
<one-to-many class="bus.NurPC" />
</set>
---------------------------------
</class>
</hibernate-mapping>
ChildCode:
<hibernate-mapping>
<class name="bus.NurPC" table="NurPC">
<id name="recID" type="int" unsaved-value="null" >
<column name="RECID" sql-type="int" not-null="true"/>
<generator class="native" />
</id>
------ First set key --------------------------------------
<property name="acctNumber">
<column name="ACCTNUMBER"/>
</property>
--------------------------------------------------------------
<property name="MIInterventionDesc">
<column name="MIINTERVENTIONDESC"/>
</property>
<property name="MIStatus">
<column name="MISTATUS"/>
</property>
<property name="MIInitDate">
<column name="MIINITDATE"/>
</property>
<property name="MIInitUser">
<column name="MIINITUSER"/>
</property>
<property name="MITargetDate">
<column name="MITARGETDATE"/>
</property>
<property name="MICMPDate">
<column name="MICMPDATE"/>
</property>
<property name="MICMPUser">
<column name="MICMPUSER"/>
</property>
<property name="startDateAndTime">
<column name="STARTDATEANDTIME"/>
</property>
<property name="MISingleDirection">
<column name="MISINGLEDIRECTION"/>
</property>
<property name="MIProtocol">
<column name="MIPROTOCOL"/>
</property>
------ Second Set Key -----------------------------------
<property name="timeStampID">
<column name="TIMESTAMPID"/>
</property>
-------------------------------------------------------------
</class>
</hibernate-mapping>
This is the error message I get:
Foreign key (FK4820E9E17A9F91F:NurPC [ACCTNUMBER,TIMESTAMPID])) must have same number of columns as the referenced primary key (PatientDoctorListRegSDC [RECID])
I would think this would work just like a join.
Code: