Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
NonUniqueObjectException was caught 
'a different object with the same identifier value was already associated with the session: 64, of entity' at SaveOrUpdate method NHibernate Exception C#


Savint Two Objects in Single Method Using SaveOrUpdate() method Showing the above exception

my code is as below
i.e., 

object1=SaveOrUpdate(object1)

forearch(var item in object2)
{
otherObjectRepository.SaveOrUpdate(item);
}


please help me to resolve the Exception.. 
Posted
Comments
Vijay Gill 10-Dec-15 15:02pm    
I presume, object2 is a list. If so, is object1 added to that list too? Also, were the objects in object2 fetched using a session different from the session used to fetch object1? Also please post a bit more information (like scenario, code etc.) for helping us help you.
CHAITANYA KIRAN KASANI 18-Dec-15 2:11am    
http://kasaniexceptions.blogspot.in/2015/12/nonuniqueobjectexception-was-caught.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900