Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
All classes are Serializable, equals and hashcode methods are available
[b]Hibernate version:[/b]
2.1.7
[b]Mapping documents:[/b]
<hibernate-mapping>
<class name="Parent" table="Parent_Table">
<composite-id name="key" class="ParentKey" unsaved-value="any">
<key-property name="dealNumber" type="long" column="DEAL_ID"/>
<key-property name="decisionId" type="long" column="DECISION_ID"/>
</composite-id>
<list name="children" table="Child_Table" inverse="true" cascade="all-delete-orphan">
<key>
<column name="DEAL_ID"/>
<column name="DCSN_ID"/>
</key>
<index column="ADJ_DATA_SEQ"/>
<one-to-many class="Child"/>
</list>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="Child" table="Child_Table">
<composite-id name="key" class="ChildKey" unsaved-value="any">
<key-many-to-one name="parent" class ="Parent">
<column name="DEAL_ID"/>
<column name="DCSN_ID"/>
</key-many-to-one>
<key-property name="adjustmentSequenceNo" type="int" column="ADJ_DATA_SEQ"/>
</composite-id>
</class>
</hibernate-mapping>
[b]Code between sessionFactory.openSession() and session.close():[/b]
Parent data = new Parent();
ParentKey key = new ParentKey();
//set the Keys
key.setDecisionId(119);
key.setDealNumber(1000);
//save Parent
data.setKey(key);
hibernateTemplate.save(data);
hibernateTemplate.flush();
//set the Child Key
Child child = new ChildData ();
ChildKey childKey = new ChildKey();
childKey .setAdjustmentSequenceNo(200);
//SAVE CHILD
Parent parent = (Parent )template.load(Parent .class, key);
child .getKey().setParent(parent);
parent.getChildren().add(child );
hibernateTemplate.save(child );
hibernateTemplate.flush();
[b]Full stack trace of any exception that occurs:[/b]
Hibernate: insert into Parent(PREM_RATE1, PREM_RATE2, PREM_RATE3, PREM_RATE4, TAX_RATE, APP_FEE, TIME_STAMP,
Hibernate: insert into Child(ADJ_RULE_ID, ADJ_VER_ID, ADJ_TYPE, ADJ_VAL1, ADJ_VAL2, ADJ_VALM3, ADJ_VAL4,
Jan 11, 2006 11:58:02 AM net.sf.hibernate.impl.SessionImpl
SEVERE: Could not synchronize database state with session
[b]Name and version of the database you are using:[/b]
DB2
[b]The generated SQL (show_sql=true):[/b]
Hibernate: insert into Parent_Table(......)
Hibernate: select parent_.DEAL_ID as DEAL_ID0_,.....
Hibernate: insert into Child_Table(ADJ_RULE_ID, ........
Jan 11, 2006 11:58:02 AM net.sf.hibernate.impl.SessionImpl
SEVERE: Could not synchronize database state with session
[b]Debug level Hibernate log excerpt:[/b]