-->
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: cascading insert for one-to-many relation parent/child table
PostPosted: Mon Aug 30, 2010 10:43 am 
Newbie

Joined: Mon Aug 30, 2010 10:29 am
Posts: 2
I have two tables with parent/child relation. Child table have two columns, both columns make a primary key.
Parent's key is one of the primary keys in child table but parent/child has one-to-many relationship so "generated key" in child table is not unique. Uniqueness is defined by combination of columns in child table. I have cascade="all" between parent/child tables. If cascading insert tries to insert more than one records of same generated key in child table then hibernate throws "noUniqueObject" exception...anyone knows how to solve this?

<id name="c1" type="int">
<column name="column1"/>
<generator class="foreign"/>
<param name="property">column1</param>
</generator>
</id>

Since there is one-to-mant relation between parent-child above configuration throws "noUniqueObject" exception at cascading insert.
I tried to define Composite-id in child table's hbm having both columns but that throws exception too.
"INSERT statement conflicted with COLUMN FOREIGN KEY constraint "


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.