Hibernate version:
3.2
I am trying to insert a parent object which contains child reference .. it is inserting the parent(evaluation) but it is not inserting any child object
Evaluation <1 is parent to *> Questionnaire <1 is parent to *> psychodiagnositch_questinnaire
one evaluation object contains a collection of questionnaire and each questinnaire contains mulitple psychodiagnostich_questionnaire.
There is no problem with hibernate connectiviti issue, since i am able to insert in single table .. i am using spring for session and other thingy.
Here are the mapping documents for 3 tables
Mapping documents:
- Evaluation
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.careway.domain.hibernate">
<class name="com.careway.domain.hibernate.EvaluationImpl" table="evaluation" optimistic-lock="none">
<id name="id" type="integer" unsaved-value="0">
<column name="id" not-null="true" unique="true" index="PRIMARY"/>
<generator class="increment"/>
</id>
<property name="evaluationDate" type="timestamp" column="evaluation_date" not-null="true"/>
<property name="instructions" type="string" column="instructions" length="300"/>
<many-to-one name="evaluatedBy" entity-name="com.careway.domain.hibernate.UserImpl" cascade="none" foreign-key="evaluation_ibfk_2" column="evaluated_by"/>
<many-to-one name="patientProfile" entity-name="com.careway.domain.hibernate.PatientProfileImpl" cascade="none" foreign-key="evaluation_ibfk_1" column="patient_profile_id"/>
<set name="questionnaire" inverse="true" cascade="none">
<key foreign-key="questionnaire_ibfk_1" not-null="true" column="evaluation_id"/>
<one-to-many entity-name="com.careway.domain.hibernate.QuestionnaireImpl"/>
</set>
</class>
</hibernate-mapping>
- Questionnaire
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.careway.domain.hibernate">
<class name="com.careway.domain.hibernate.QuestionnaireImpl" table="questionnaire" optimistic-lock="none">
<id name="id" type="integer" unsaved-value="0">
<column name="id" not-null="true" unique="true" index="PRIMARY"/>
<generator class="increment"/>
</id>
<property name="dateTime" type="timestamp" column="date_time"/>
<many-to-one name="questionnaireType" entity-name="com.careway.domain.hibernate.QuestionnaireTypeImpl" cascade="none" foreign-key="questionnaire_ibfk_2" column="questionnaire_type_id"/>
<many-to-one name="evaluation" entity-name="com.careway.domain.hibernate.EvaluationImpl" cascade="none" foreign-key="questionnaire_ibfk_1" column="evaluation_id"/>
<set name="psychodiagnostichQuestionnaire" inverse="true" cascade="none">
<key foreign-key="psychodiagnostich_questionnaire_ibfk_1" column="questionnaire_id"/>
<one-to-many entity-name="com.careway.domain.hibernate.PsychodiagnostichQuestionnaireImpl"/>
</set>
</class>
</hibernate-mapping>
- Psycho ...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.careway.domain.hibernate">
<class name="com.careway.domain.hibernate.PsychodiagnostichEvaluationResultImpl" table="psychodiagnostich_evaluation_result" optimistic-lock="none">
<id name="id" type="integer" unsaved-value="0">
<column name="id" not-null="true" unique="true" index="PRIMARY"/>
<generator class="increment"/>
</id>
<property name="instructions" type="string" column="instructions" length="300"/>
<property name="identifiedCategory" type="string" column="identified_category" length="50" not-null="true"/>
<property name="threatLevel" type="integer" column="threat_level" not-null="true"/>
<many-to-one name="evaluationResult" entity-name="com.careway.domain.hibernate.EvaluationResultImpl" cascade="none" foreign-key="psychodiagnostich_evaluation_result_ibfk_1" column="evaluation_result_id"/>
</class>
</hibernate-mapping>