Hi
We have 2 tables and these are their columns & relationships
Code:
Table 1: PTNT_MSR
Columns :
PTNT_DATA_MSRMNT_CLCTN_ID : PK
PTNT_PRCTC_PRFMNC_YR_ID
DEMO_PRCTC_DATA_CLCTN_PRD_ID
Table 2: PTNT_DTL
Columns:
PTNT_DTL_ID : PK
PTNT_DATA_MSRMNT_CLCTN_ID : FK
PTNT_1ST_NAME
PTNT_MDL_NAME
PTNT_LAST_NAME
There are some more columns in PTNT_DTL which I have left out and one more table that is not needed.
Hibernate mapping:
Code:
<class name="PatientDataMeasure" table="PTNT_MSR">
<id name="patientDataMeasurementCollectionId"
column="PTNT_DATA_MSRMNT_CLCTN_ID"
type="long">
<generator class="assigned" />
</id>
<property name="demoCollectionPeriodId"
column="DEMO_PRCTC_DATA_CLCTN_PRD_ID"
type="long" />
<many-to-one name="patientDetail" class="PatientDetail" property-ref="patientDataMeasurementCollectionId"
column="PTNT_DATA_MSRMNT_CLCTN_ID" fetch="join" not-null="true" insert="false" update="false" />
<many-to-one name="patientPracticePerformanceYear" class="PatientPracticePerformanceYear"
column="PTNT_PRCTC_PRFMNC_YR_ID" fetch="join" not-null="true" insert="false" update="false" />
</class>
The code works fine for select(get/load). The problem is when I try to insert/update PatientDetail. If i remove insert="false" and update="false", then I get the error:
Code:
gov.hhs.cms.ehrds.datacollection.model.PatientDataMeasurementCollection column: PTNT_DATA_MSRMNT_CLCTN_ID (should be mapped with insert="false" update="false")
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: gov.hhs.cms.ehrds.datacollection.model.PatientDataMeasurementCollection column: PTNT_DATA_MSRMNT_CLCTN_ID (should be mapped with insert="false" update="false")
I understand that the column "PTNT_DATA_MSRMNT_CLCTN_ID" is repeated. Is there any other way to go about this. I need to save/update the PatientDetails. Appreciate your suggestions
Thanks
Harish