-->
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: exception on delete
PostPosted: Thu Feb 05, 2004 4:48 am 
Newbie

Joined: Thu Jan 15, 2004 5:04 am
Posts: 6
when i execute the following:
Code:
Session hs = ..;
hs.delete(someObject);


i get exception:
    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)

I don't understand why.

Could you help me?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2004 5:33 am 
Regular
Regular

Joined: Wed Dec 31, 2003 4:26 am
Posts: 108
Location: Berkeley, CA
I think the exception explains the problem. It seems you are trying to delete an object that is actively in a relationship with another object. Most likely the object in question (the one being deleted) is in a Set that belongs to another object.

So, either change the cascade properties on that set in the corresponding hibernate mapping file, or make sure you remove the object you are deleting from its associations.

By the way, with proper cascading properties, removing an object from the set and then commiting the changes (e.g., session.flush()) will delete the corresponding db record.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 07, 2004 10:29 am 
Newbie

Joined: Wed Sep 24, 2003 12:14 pm
Posts: 16
Location: Brazil
Hi
I've the same issues...is there any news here?
Thanks!

_________________
Paulo Alvim
Powerlogic - Brazil


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.