-->
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: HibernateException: reassociated object has dirty collection
PostPosted: Wed Feb 25, 2004 10:21 am 
I have already described this problem in a reply to another topic [NullPointerException in SessionImpl.getOrphans()], but nobody seems to look at it. So here it is again ;-)

In the other topic, Gavin asked me to put a line of code into Hibernate 2.1.2 in order to fix another issue:

Quote:
Add the following line to SessionImpl.doUpdateMutable():
Code:
if ( ( (Lifecycle) object ).onUpdate(this) ) {  // do callback
   log.debug("update vetoed by onUpdate()");
   reassociate(object, id, persister); //<---- New Line!
   return;
}


The new line of code fixed my problem, but I believe it might be be responsible for another problem I now have in the constellation decribed below. I believe this because the new line of code appears in the stack trace.

Class A has a one-to-many collection of class B with cascade="all-delete-orphan", inverse="true". Class B has a many-to-one reference to class C, which in turn has a one-to-many collection of class B with cascade="all-delete-orphan", inverse="true".

The entire object graph consists of detached objects. I want to remove an instance of B by removing if from the collections in A and C. When I call saveOrUpdate(), the instance of C vetoes the update for application-specific reasons. This causes the operation to fail with
HibernateException: reassociated object has dirty collection (details below)

I do understand the general reason why this exception would be thrown, but I am not sure that it is appropriate in this case for several reasons:
1. The table containing C doesn't need to be updated, so no problem.
2. The collection has inverse="true", so it is not C's job to maintain it.
3. This was not a problem in 2.1 final (not sure that counts).

net.sf.hibernate.HibernateException: reassociated object has dirty collection
at net.sf.hibernate.impl.OnLockVisitor.processCollection(OnLockVisitor.java:47)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.AbstractVisitor.process(AbstractVisitor.java:93)
at net.sf.hibernate.impl.SessionImpl.reassociate(SessionImpl.java:1654)
at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1420)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1441)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1364)
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.doUpdate(SessionImpl.java:1446)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1364)


Top
  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 1:33 pm 
Newbie

Joined: Tue Sep 23, 2003 4:52 pm
Posts: 5
I've also experienced this similar problem. Does anyone have a patch that will fix this issue or will I have to wait for Hibernate 2.2?

Thanks so much,
Dino


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 12:18 pm 
Newbie

Joined: Tue Sep 23, 2003 4:52 pm
Posts: 5
bumping the thread.

Hoping someone will look at it.... pretty please?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 24, 2004 1:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Looked at this and I am happy with the behavior.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 28, 2004 12:05 pm 
Just to clarify: you are saying that if a collection is dirty on an object, the lifecycle method onUpdate() cannot veto the update, even if the relationship has inverse="true"?


Top
  
 
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.