-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Insert with one-to-many association (bidirectional).
PostPosted: Tue Oct 02, 2007 5:04 am 
Newbie

Joined: Tue Oct 02, 2007 1:47 am
Posts: 6
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.