-->
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: NonUniqueObjectException
PostPosted: Mon Jan 26, 2004 2:38 am 
Regular
Regular

Joined: Tue Sep 09, 2003 9:37 pm
Posts: 56
Location: Ogden, Utah, USA
I get a NonUniqueObjectException when deleting an object during cleanup in a junit test.

Here are the basic steps:
new session
create object
save object
close session - object is now detached
new session
hql query, loads a different instance of the same object into a list
delete detached copy of the object

This generates a NonUniqueObjectException. If I lock the object, reassociating it with the current session before trying to delete it, the lock causes the NonUniqueObjectException. If I lock the object before running the HQL query, it works fine.

Am I doing something that I shouldn't be? Is there a correct way to reattach an object that may have been otherwise loaded in the interim since it was detached?

Thanks for your help!
Jenica


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 2:59 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You cannot have 2 attached instance of the same persistent object (same id). I you load the object and then attach a transiant copy, then it will fail.
You can evict() the already attached object before attaching the other instance.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Comments please...
PostPosted: Thu Aug 19, 2004 3:08 pm 
Newbie

Joined: Thu Aug 19, 2004 7:57 am
Posts: 14
emmanuel wrote:
You cannot have 2 attached instance of the same persistent object (same id). I you load the object and then attach a transiant copy, then it will fail.
You can evict() the already attached object before attaching the other instance.


Emmanuel,

Could you comment on the following post? It sound's like you know what is going on, but from this post, I still don't quite understand what I'm doing wrong.

http://forum.hibernate.org/viewtopic.php?t=933689

_________________
Andy Czerwonka


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.