After an exception was thrown, the session is no longer usable, create a new
session

On Tue, Sep 30, 2008 at 11:12 AM, Pedro Santos <[EMAIL PROTECTED]>wrote:

>
> Hello,
>
> We've been having a strange problem ever since we upgraded to
> NHibernate 2.0.0 (I upgraded yesterday 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: 34, 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 we 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
>
> More:
>
> » We may have several processes interacting with the DB at the same
> time (web and a batch process)
> » We use native id generator
> » We don't override Equals or GetHashCode
>
> Can anyone help us?
> Thank you!
>
> PS: Stack trace and mapping file below.
>
> Here's the full stack trace:
>
> [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
>
> Here's the mapping:
>
> <class      name="OrionsBelt.DataAccessLayer.SpecializedExceptionInfo,
> OrionsBelt.DataAccessLayer"
>            table="ExceptionInfo"
>            discriminator-value="-1039632119">
>      <id name="Id" type="Int32" column="ExceptionInfoID">
>         <generator class="native" />
>      </id>
>      <property name="Name" column="Name" type="String"
> length="15000" />
>      <property name="Message" column="Message" type="String"
> length="15000" />
>      <property name="Date" column="Date" type="DateTime"  />
>      <many-to-one name="PrincipalNHibernate" column="PrincipalID" not-
> null="false" />
>      <property name="Url" column="Url" type="String" length="15000" /
> >
>      <property name="StackTrace" column="StackTrace" type="String"
> length="15000" />
>      <property name="CreatedDate" column="CreatedDate"
> type="DateTime"  />
>      <property name="UpdatedDate" column="UpdatedDate"
> type="DateTime"  />
>      <property name="LastActionUserId" column="LastActionUserId"
> type="Int32"  />
>   </class>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to