I have two tables: patient_data and patient_diagnosis Patient_data conatins personal data of patient like: pid (pkey), gender, birth_date patient_diagnosis contains the diagnosis data of the registered patients. It has fileds like: record_id (pkey), pid (fkey to patient_data(pid)), diagnosis_date and other related fields. Now, I want to join these two tables on pid and have all these fields in a single type of object. Here is the mapping file:
<hibernate-mapping> <class catalog="emr" name="in.Models.Emr" table="patient_diagnosis"> <id name="recordid" type="long"> <column name="record_id"/> </id> <property name="diagnosisDate" type="timestamp"> <column length="19" name="diagnosis_date" not-null="true"/> </property> <property name="snomedTermPrimary" type="long"> <column name="snomed_term_primary" not-null="true" /> </property> <property name="snomedTermSecondary" type="string"> <column name="snomed_term_secondary" /> </property> <property name="episodeNo" type="long"> <column name="episode_no" not-null="true" /> </property> <property name="pid" type="long"> <column name="pid" not-null="true" /> </property> <join table="patient_data"> <key column="pid"/> <property name="gender" type="string"> <column name="gender" not-null="true"/> </property> <property name="birthDate" type="timestamp"> <column length="19" name="birth_date" not-null="true"/> </property>
</join> </class> </hibernate-mapping>
But, the join applies on patient_diagnosis.record_id = patient_data.pid instead of patient_diagnosis.pid = patient_data.pid i.e. HQL applies on primary key of first table with mentioned column from second table. Please provide the solution so that join can be applied on mentioned column from first with mentioned column fro second table. Or is there a other way out.
Please note that in case I didn't create classes for patient_data or patient_diagnosis. But, just Emr class having combination of fields of these tables is created.
TIA
|