-->
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.  [ 3 posts ] 
Author Message
 Post subject: Flush during cascade is dangerous
PostPosted: Mon Jun 27, 2005 1:25 am 
Newbie

Joined: Mon Jun 27, 2005 1:11 am
Posts: 2
I have a hibernate list mapping like below ( for class MainClass)


<list name="cs" cascade="all-delete-orphan" lazy="true" >
<key column="Id"/>
<index column="IndexCol"/>
<one-to-many class="Class1"/>
</list>

<list name="hs" cascade="all-delete-orphan" lazy="true" >
<key column="Id"/>
<index column="IndexCol"/>
<one-to-many class="Class2"/>
</list>

when I execute a piece of code

Transaction tx = session.beginTransaction();
Class2 cl2 = (Class2) cl1;//cl1 is object of Class1
MainClass mc = new MainClass();
mc.getCS().remove(cl1);
mc.getHS().add(cl2);
session.save(mc);
tx.commit();

its throwing exception :


javax.servlet.ServletException: root cause: Flush during cascade is dangerous
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.makeit_jsp._jspService(makeit_jsp.java:131)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)


pls.help me in solving this proble ASAP

_________________
PAluri


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 27, 2005 8:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please use the website search. There are various FAQ entries about that:

http://www.hibernate.org/117.html#A25
http://www.hibernate.org/74.html#A13


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 27, 2005 8:50 am 
Newbie

Joined: Mon Jun 27, 2005 1:11 am
Posts: 2
"This almost always happens because you forgot to remove a deleted instance from an association with cascading save enabled. You should remove deleted objects from associations before flushing the session. Basically, the object you're trying to delete would be resaved to the database by it being in a collection hanging off another object. You need to remove it from other collections before deleting it. "


As said above , I am removing the object from the collection and then I am trying to save it but still I am getting the exception

_________________
PAluri


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.