NHibernate Failed to Synchronize Database State with Session

I checked the NHibernate log files and found random errors as shown below:

NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [MaltaIndependent.Modules._AutoGen.MemberImpl#353796206] at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2821 at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2702 at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session) in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 3007 at NHibernate.Action.EntityUpdateAction.Execute() in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Action\EntityUpdateAction.cs:line 79 at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Engine\ActionQueue.cs:line 136 at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Engine\ActionQueue.cs:line 125 at NHibernate.Engine.ActionQueue.ExecuteActions() in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Engine\ActionQueue.cs:line 171 at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) in c:\Repository\Work\CodeBase\C#\+OpenSource\nHibernate\nhibernate-core-master-v3.3.1\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 241 

Regarding this issue, I know that this is due to the optimism of concurrency and is "expected". My main concern is stack trace. Nowhere does it declare "where", and it runs the string NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecution . I tried downloading the NHibernate source code and taking a look, but could not understand why the full stack trace is not displayed. I have other stack traces for similar errors that put me in the Transaction.Commit() . Any ideas how I can find which part of the code is actually throwing an error?

+4
source share
1 answer

I had the same problem and it turned out that I had LazyLoad setting in the displayed field (not a link or hasmany).

NH should give you which object caused the error

I hope you decide this soon

0
source

Source: https://habr.com/ru/post/1444757/


All Articles