I had solved that issue,
but have come up with the same Exception in another place.
Every time I try to save a new PatientFlowsheetElement Object, It throws the same exception.
Hibernate has an update="false" in <many-to-one> tag, but
How do I give an update="false" on <key-many-to-one> tag.
How do I tell Hibernate that when you are trying to insert the parent object, don't try to insert the object which is supplied for insertion of key value in the parent Object.
/********************PatientFlowsheetElementParam**************/
Code:
<class name="PatientFlowsheetElementParam" table="patient_flowsheet_element_param">
<composite-id name="id">
<key-many-to-one name="patientFlowsheetElementId" column="PATIENT_FLOWSHEET_ELEMENT_ID" class="PatientFlowsheetElement"/>
<key-many-to-one name="parameterId" column="PARAMETER_ID" class="com.ge.healthcare.gehcit.ehrae.variable.dto.Variable" />
</composite-id>
<timestamp name="lastUpdateTime" column="LAST_UPDATE_TIME"/>
<property name="sequence" column="SEQUENCE" type="java.lang.Integer" not-null="true" />
<property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" not-null="true" />
</class>
/********************PatientFlowsheetElement**************/
Code:
<class name="PatientFlowsheetElement" table="patient_flowsheet_element" dynamic-update="false">
<id name="patientFlowsheetElementId" column="PATIENT_FLOWSHEET_ELEMENT_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<timestamp name="lastUpdateTime" column="LAST_UPDATE_TIME"/>
<property name="elementType" column="ELEMENT_TYPE" type="java.lang.String" />
<property name="elementName" column="ELEMENT_NAME" type="java.lang.String" />
<property name="lastUpdateUser" column="LAST_UPDATE_USER" type="java.lang.String" />
<property name="sequence" column="SEQUENCE" type="java.lang.Integer" />
<many-to-one name="patientFlowsheet" column="PATIENT_FLOWSHEET_ID" class="PatientFlowsheet"/>
<many-to-one name="patientFlowsheetElement" column="PATIENT_FLOWSHEET_PARENT_ID" class="PatientFlowsheetElement" />
<bag name="childPatientFlowsheetElements" table="patient_flowsheet_element" cascade ="save-update,delete" inverse="true" lazy="false">
<key column="PATIENT_FLOWSHEET_PARENT_ID" />
<one-to-many class="PatientFlowsheetElement"/>
</bag>
<set name="patientFlowsheetElementParams" table="patient_flowsheet_element_param" cascade="save-update,delete" inverse="true" lazy="false">
<key column="PATIENT_FLOWSHEET_ELEMENT_ID" />
<one-to-many class="PatientFlowsheetElementParam" />
</set>
</class>
Any help would be deeply appreciated. Please tell me if you are not able to understand. I'll try rephrasing my question.