-->
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.  [ 2 posts ] 
Author Message
 Post subject: hibernate update() problem
PostPosted: Thu Jan 18, 2007 11:22 am 
Newbie

Joined: Thu Nov 30, 2006 10:06 am
Posts: 9
I have Site entity and a set of site domains:
Code:
<class name="Site">
   <id column="ID" ...>
   <set name="siteDomains" cascade="all" >
      <key column="SITE_ID"/>
      <one-to-many class="SiteDomain"/>
   </set>
</class>

<class name="SiteDomain">
   <id name="id"..>
   <property name="domain" column="SITE_DOMAIN" type="string" unique="true"/>
</class>


When I need to update site domains from form I use simply:
hibernateTemplate.update(site);

but it violates the unique constraint for SITE_DOMAIN column, because Hibernate tries first to add new row in site domain table. When I try first to delete all site domain collection I get an exception

hibernateTemplate.deleteAll(site.getSiteDomains());

Code:
org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: deleted object would be re-saved by cascade (remove deleted object from associations)


Any suggestions how to tackle that?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 2:39 am 
Newbie

Joined: Tue Dec 19, 2006 11:05 am
Posts: 11
You have to remove the child records from the Java-Set first...


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

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.