What is the value of RowVersion immediately before you try to persist Save, and Commit, respectively?
/Oskar 2015-02-11 11:57 GMT+00:00 alrhr <[email protected]>: > After updating my solution from NHibernate 3.4.0GA to 4.0.3GA I have > problems with RowVersion whenever I SaveOrUpdate a new entity. > My mappings are created with the newest Version of FluentNHibernate (2.0.1). > > public class MapMatrixColumn : ClassMap<EntMatrixColumn> > { > public MapMatrixColumn() > { > Table("MatrixColumn"); > > Id(x => x.Id) > .GeneratedBy.HiLo("1000") > .UnsavedValue(-1); > > Version(x => x.RowVersion); > ... > ... > > > What irritates me most is that these "show stopping" errors have not been > reported by other users. > I tried out the older versions 4.0.0GA and 4.0.2GA too. The result was the > same. > > At first my RowVersion was declared as Nullable<int>. No problem in NH > 3.4.0. In NH 4 the following exception was thrown: > > The object reference was not set to an instance of an object > > at NHibernate.Type.Int32Type.Next(Object current, ISessionImplementor > session) > at NHibernate.Engine.Versioning.Increment(Object version, IVersionType > versionType, ISessionImplementor session) > at > NHibernate.Event.Default.DefaultFlushEntityEventListener.GetNextVersion(FlushEntityEvent > event) > at > NHibernate.Event.Default.DefaultFlushEntityEventListener.ScheduleUpdate(FlushEntityEvent > event) > at > NHibernate.Event.Default.DefaultFlushEntityEventListener.OnFlushEntity(FlushEntityEvent > event) > at > NHibernate.Event.Default.AbstractFlushingEventListener.FlushEntities(FlushEvent > event) > at > NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent > event) > at > NHibernate.Event.Default.DefaultAutoFlushEventListener.OnAutoFlush(AutoFlushEvent > event) > at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet`1 querySpaces) > at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, > QueryParameters queryParameters, IList results) > at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression > queryExpression, QueryParameters parameters) > at NHibernate.Impl.AbstractQueryImpl2.List() > at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression > nhLinqExpression, IQuery query, NhLinqExpression nhQuery) > at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) > at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression > expression) > at System.Linq.Queryable.Single[TSource](IQueryable`1 source) > > Next I changed the declaration of RowVersion from Nullable<int> to int > resulting in a StaleObjectStateException: > > Row was updated or deleted by another transaction (or unsaved-value mapping > was incorrect) > 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) > 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) > at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, > Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] > oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor > session) > at NHibernate.Action.EntityUpdateAction.Execute() > at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) > at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) > at NHibernate.Engine.ActionQueue.ExecuteActions() > at > NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource > session) > at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent > event) > at NHibernate.Impl.SessionImpl.Flush() > at NHibernate.Transaction.AdoTransaction.Commit() > > Any ideas? This exception makes absolutely no sense when trying to persist a > new entity. > > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
