Hello,
We've been having a strange problem ever since we upgraded to NHibernate 2.0.0 (I upgraded today to 2.0.1 but the problem still persists). The problem is: sometimes, and I really mean sometimes, we have an exception like this one:
a different object with the same identifier value was already associated with the session: 0, of entity: OrionsBelt.DataAccessLayer.SpecializedExceptionInfo
Note that this only occurs when we throw an exception. After throwing, we try to store it on the DB creating a SpecialziedExceptionInfo to store the exception and using NHibernate to persist it.
Now, this exception only happens sometimes... we can stay all day long without it. When we start to have it, it usually happens for sometime, but if the restart the process everything works fine again.
More information about the problem pipeline:
» We are on an ASP.NET environment
» We open an NHibernate connection (if needed) on every request, and we dispose of it at the end of the request. All interaction with the DB on a given request is made using that connection
» If there's some exception we throw it, catch it, store it to a SpecializedExceptionInfo and persist it to the DB using NH
» If there's *another* exception, or sometimes another actions, we may get the problem I'm presenting
Can anyone help us?
Here's the full stack trace:
Code:
[NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 0, of entity: OrionsBelt.DataAccessLayer.SpecializedExceptionInfo]
NHibernate.Engine.StatefulPersistenceContext.CheckUniqueness(EntityKey key, Object obj) +170
NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate(Object entity, EntityKey key, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) +630
NHibernate.Event.Default.AbstractSaveEventListener.PerformSave(Object entity, Object id, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) +452
NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) +144
NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) +42
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event) +128
NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) +85
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event) +199
NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) +45
NHibernate.Impl.SessionImpl.Save(Object obj) +44
OrionsBelt.DataAccessLayer.NHibernatePersistance`1.Update(T t) in I:\psantos\Sirius\Trunk\DataAccessLayer\NHibernate\Persistance.cs:368
OrionsBelt.DataAccessLayer.ExceptionLogger.Log(Exception ex) in I:\psantos\Sirius\Trunk\DataAccessLayer\Exceptions\ExceptionLogger.cs:26
OrionsBelt.WebComponents.LanguageResources.Get(String key) in I:\psantos\Sirius\Trunk\WebComponents\Localization\LanguageResources.cs:60
OrionsBelt.WebComponents.LanguageManager.Get(String language, String key) in I:\psantos\Sirius\Trunk\WebComponents\Localization\LanguageManager.cs:175
OrionsBelt.WebComponents.LanguageManager.Get(String key) in I:\psantos\Sirius\Trunk\WebComponents\Localization\LanguageManager.cs:163
OrionsBelt.WebUserInterface.Engine.WebUtilities.Compare(IResourceInfo r1, IResourceInfo r2) in I:\psantos\Sirius\Trunk\WebUserInterface\Engine\WebUtilities.cs:79
System.FunctorComparer`1.Compare(T x, T y) +19
System.Collections.Generic.ArraySortHelper`1.SwapIfGreaterWithItems(T[] keys, TValue[] values, IComparer`1 comparer, Int32 a, Int32 b) +125