Hi,
1. I am trying to insert a new parent with one-to-many association where child is a Set as collection element. I do have the parent id generated by sequence.
I m using oracle 9i.
2. Parent mapping file looks like this :
<class
name="com.capgent.cpt.common.to.RlHdr"
table="RL_HDR"
lazy="false">
<id name="rlId" type="java.lang.Integer" unsaved-value="null">
<column name="RL_ID" not-null="true"/>
<generator class="increment"/>
</id>
<set
name="rlaLnkhdrs"
lazy="false"
inverse="true"
cascade="all">
<key>
<column name="RL_ID" not-null="true"/>
</key>
<one-to-many
class="com.capgent.cpt.common.to.RlaLnkhdr"/>
</set>
3. Child mapping file looks like this :
<class
name="com.capgent.cpt.common.to.RlaLnkhdr"
table="RLA_LNKHDR"
lazy="false">
<composite-id name="comp_id" class="com.capgent.cpt.common.to.RlaLnkhdrPK">
<key-property
name="rlId"
column="RL_ID"
type="java.lang.Integer"
length="8"
/>
<key-property
name="actId"
column="ACT_ID"
type="java.lang.Integer"
length="8"/>
</composite-id>
<many-to-one
name="rlHdr"
class="com.capgent.cpt.common.to.RlHdr"
update="false"
insert="false">
<column name="RL_ID" not-null="true"/>
</many-to-one>
4. Also, in my code, when i creates new Child object , i set the parent in its constructor itself, with parent id being already set.
5. It throws exception saying :
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update ...
Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (OMNICOMTEST.SYS_C008980) violated - parent key not found ...
What am i missing ...
Thanks,
Pragati
|