-->
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.  [ 2 posts ] 
Author Message
 Post subject: a different object with the same identifier value was alread
PostPosted: Wed Oct 26, 2005 10:26 pm 
a different object with the same identifier value was already associated with the session: dbf828e9-29d3-4ad6-86dc-f4b75f5ac573, of class:

why??


Top
  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 6:20 am 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
I would certainly need a second opinion on that but here is how I ran into this and what the cause was:

If you attach an object to a session (Save, Lock) and the object was previously loaded with the session this exception occurs. If this situation seems unlikely to you, you should consider also this case when you have cascading enabled on some braches.

Eg.
class Country { CountryId, Name }
class City ( CityId, Country, Name }, City has cascade all with Country.

Load the city { 1, {1, "USA"} , "New York" } (note that the country is eagerly loaded) and than evict it.

Create a new session, load another city { 2, {1, "USA}, "Manhattan" }. If you try now to save the "New York" object using the second session you will receive this error because you have a different instance of "USA" already associated with the session and nHibernate tries to attach the country object to the session because of the cascading.

The fun part is that I have the impression that this did not happen in previous versions of NHibernate.


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