Hi Guys,
I have a question about getting a NotUniqueObjectException.
I have an object with a collection of objects that point to other immutable objects in a Many to Many relationship. The objects at the end of the Many to Many relation ship are basically "Lookup" objects. I get this exception when one of these objects turns up more then once in my object tree (As a lookup value should) and I Lock a detached object back onto a new session.
The exception is pretty clear:
NonUniqueObjectException: 'a different object with the same identifier value was already associated with the session'
I have debugged this alot and have found that Reassociate is getting called for all objects in my object tree.
There is an IdentityMap dictionary called entityEntries in the NHibernate session obect that the Lock method uses before calling Reassociate to check if the object has already been added to the session and get session information about the object. When my object comes along for the second time this dictionary can't find it in the map (I can see it in there!!) and returns Null. This causes the Reassociate to run on an object that's already in the entitiesByKey dictionary and therefore the exception as it's representing the same object.
I think that my lookup objects are different instances, but with identical data.
What I would like to know, is what is the Identity Map object using to compare my objects that means it doesn't find this object when it's already in there. Is it some hashing magic that can see my objects are different ??
Hibernate version: 1.0.1.0
Full stack trace of any exception that occurs:
NHibernate.DLL!NHibernate.Impl.SessionImpl.CheckUniqueness(NHibernate.Engine.Key key = {33}, object obj = {3118 : FOOD: Bakery Products}) Line 1903
NHibernate.DLL!NHibernate.Impl.SessionImpl.Reassociate(object obj = {3118 : FOOD: Bakery Products}, object id = 33, NHibernate.Persister.IClassPersister persister = {NHibernate(HSI.Business.Impl.IndustryCode)}) Line 1912 + 0xd bytes
NHibernate.DLL!NHibernate.Impl.SessionImpl.Lock(object obj = {3118 : FOOD: Bakery Products}, NHibernate.LockMode lockMode = {None}) Line 1953 + 0x12 bytes
NHibernate.DLL!NHibernate.Engine.Cascades.CascadingAction.ActionLockClass.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object child = {3118 : FOOD: Bakery Products}, object anything = {None}) Line 125 + 0x2d bytes
NHibernate.DLL!NHibernate.Engine.Cascades.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object child = {3118 : FOOD: Bakery Products}, NHibernate.Type.IType type = {NHibernate.Type.ManyToOneType}, NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.Cascades.CascadeStyle style = {NHibernate.Engine.Cascades.CascadeStyle.StyleAllClass}, NHibernate.Engine.CascadePoint cascadeTo = CascadeOnUpdate, object anything = {None}) Line 559 + 0x11 bytes
NHibernate.DLL!NHibernate.Engine.Cascades.CascadeCollection(NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.Cascades.CascadeStyle style = {NHibernate.Engine.Cascades.CascadeStyle.StyleAllClass}, NHibernate.Type.PersistentCollectionType collectionType = {NHibernate.Type.SetType for HSI.Business.Impl.Experience.IndustryCodes}, NHibernate.Type.IType elemType = {NHibernate.Type.ManyToOneType}, object child = {Iesi.Collections.ListSet}, NHibernate.Engine.CascadePoint cascadeVia = CascadeOnUpdate, NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object anything = {None}) Line 677 + 0x1a bytes
NHibernate.DLL!NHibernate.Engine.Cascades.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object child = {Iesi.Collections.ListSet}, NHibernate.Type.IType type = {NHibernate.Type.SetType for HSI.Business.Impl.Experience.IndustryCodes}, NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.Cascades.CascadeStyle style = {NHibernate.Engine.Cascades.CascadeStyle.StyleAllClass}, NHibernate.Engine.CascadePoint cascadeTo = CascadeOnUpdate, object anything = {None}) Line 579 + 0x1e bytes
NHibernate.DLL!NHibernate.Engine.Cascades.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, NHibernate.Persister.IClassPersister persister = {NHibernate(HSI.Business.Impl.Experience)}, object parent = {Senior Manager, Sales and Customer Service Systems}, NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.CascadePoint cascadeTo = CascadeOnUpdate, object anything = {None}) Line 638 + 0x3e bytes
NHibernate.DLL!NHibernate.Impl.SessionImpl.Lock(object obj = {Senior Manager, Sales and Customer Service Systems}, NHibernate.LockMode lockMode = {None}) Line 1958 + 0x19 bytes
NHibernate.DLL!NHibernate.Engine.Cascades.CascadingAction.ActionLockClass.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object child = {Senior Manager, Sales and Customer Service Systems}, object anything = {None}) Line 125 + 0x2d bytes
NHibernate.DLL!NHibernate.Engine.Cascades.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object child = {Senior Manager, Sales and Customer Service Systems}, NHibernate.Type.IType type = {NHibernate.Type.ManyToOneType}, NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.Cascades.CascadeStyle style = {NHibernate.Engine.Cascades.CascadeStyle.StyleAllDeleteOrphanClass}, NHibernate.Engine.CascadePoint cascadeTo = CascadeOnUpdate, object anything = {None}) Line 559 + 0x11 bytes
NHibernate.DLL!NHibernate.Engine.Cascades.CascadeCollection(NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.Cascades.CascadeStyle style = {NHibernate.Engine.Cascades.CascadeStyle.StyleAllDeleteOrphanClass}, NHibernate.Type.PersistentCollectionType collectionType = {NHibernate.Type.SetType for HSI.Business.Impl.Candidate.Experiences}, NHibernate.Type.IType elemType = {NHibernate.Type.ManyToOneType}, object child = {Iesi.Collections.ListSet}, NHibernate.Engine.CascadePoint cascadeVia = CascadeOnUpdate, NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object anything = {None}) Line 677 + 0x1a bytes
NHibernate.DLL!NHibernate.Engine.Cascades.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, object child = {Iesi.Collections.ListSet}, NHibernate.Type.IType type = {NHibernate.Type.SetType for HSI.Business.Impl.Candidate.Experiences}, NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.Cascades.CascadeStyle style = {NHibernate.Engine.Cascades.CascadeStyle.StyleAllDeleteOrphanClass}, NHibernate.Engine.CascadePoint cascadeTo = CascadeOnUpdate, object anything = {None}) Line 579 + 0x1e bytes
NHibernate.DLL!NHibernate.Engine.Cascades.Cascade(NHibernate.Engine.ISessionImplementor session = {NHibernate.Impl.SessionImpl}, NHibernate.Persister.IClassPersister persister = {NHibernate(HSI.Business.Impl.Candidate)}, object parent = {ADAMO, Steven J (5622)}, NHibernate.Engine.Cascades.CascadingAction action = {NHibernate.Engine.Cascades.CascadingAction.ActionLockClass}, NHibernate.Engine.CascadePoint cascadeTo = CascadeOnUpdate, object anything = {None}) Line 638 + 0x3e bytes
NHibernate.DLL!NHibernate.Impl.SessionImpl.Lock(object obj = {ADAMO, Steven J (5622)}, NHibernate.LockMode lockMode = {None}) Line 1958 + 0x19 bytes
HSI.Business.DLL!HSI.Business.Persister.LazyCollectionLoader.LoadCollection(Object anObject = {HSI.Business.Impl.Candidate}, String collectionName = "_addresses") Line 22 + 0x1d bytes
HSI.Business.DLL!HSI.Business.Facade.Loader.Load(Object anObject = {HSI.Business.Impl.Candidate}, String collectionName = "_addresses") Line 24 + 0x13 bytes
HSI.Business.DLL!HSI.Business.Impl.Candidate.get_Addresses() Line 374 + 0xd bytes
App_Web_t0gkrlzw.dll!Search.btAddresses_Click(Object sender = {Text = "|address|"}, System.EventArgs e = {System.EventArgs}) Line 548 + 0x1a bytes
[/b]
|