-->
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.  [ 5 posts ] 
Author Message
 Post subject: Flush during cascade is dangerous
PostPosted: Tue Nov 30, 2004 1:37 am 
Newbie

Joined: Tue Nov 30, 2004 1:33 am
Posts: 3
Location: Austin, Texas, USA
Can anyone tell what this error message means? I can't seem to find anywhere on the web what exactly this message is referring to. This error occurs when I do a session.delete() on an object that contains a collection of other objects. If I can just find out what this means, I can probably figure out what I'm doing wrong.

Thanks!



Hibernate version:2.1.6

Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: Flush during cascade is dangerous - this might occur if an object was deleted and then re-saved by cascade (remove deleted object from associations)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2181)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:709)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1310)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
at net.sf.hibernate.impl.SessionImpl.preFlushEntities(SessionImpl.java:2557)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2197)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2186)
at org.solley.persistence.PopulateDB.main(PopulateDB.java:189)

Name and version of the database you are using:
MySQL 4


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 1:44 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 6:46 pm
Posts: 41
Location: Auckland, New Zealand
Well there's a FAQ entry on this.

http://www.hibernate.org/117.html#A24

I've encountered this before. 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. At least, that was the situation for me...

HTH

Craig


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Tue Nov 30, 2004 11:39 am 
Newbie

Joined: Tue Nov 30, 2004 1:33 am
Posts: 3
Location: Austin, Texas, USA
Craig,

Thanks for the reply. I had been focusing on removing references to objects down the tree, but it never even occurred to me that the object was a member of a collection held in an object up the tree. I'll try what you suggest and see what happens. I think that will probably fix my problem though. I had seen the FAQ, but it was so terse I wasn't really clear on the problem.

Thanks again,

Tim


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 11:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I added cds' explanation to the FAQ item, thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 12:37 pm 
Newbie

Joined: Tue Nov 30, 2004 1:33 am
Posts: 3
Location: Austin, Texas, USA
Michael,

Thanks for updating the FAQ. I'm sure someone will find it useful.

Tim


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