To get an exception you have to lock the object in the session, before updating it. Nhibernate standards works in a optimistic locking way.
On 24 jul, 13:57, Kris-I <[email protected]> wrote: > Hello, > > In my employee mapping file, I have this : > <version name="_persistenceVersion" column="RowVersion" access="field" > type="int" unsaved-value="0"/> > > In the employee class : > public virtual int RowVersion { get { return _persistenceVersion; } set; } > > When I save, the value is incremented, that's ok. > > It's an ASP.NET MVC application, I launch Firefox and open 2 tabs, I > show the same employee on both. On the first, I do a change and save > ... ok. On the second, I do a change and save ..... and that's work > and no exception. > > I tried on debug. I place a breakpoint before the save, when the > cursor reach the beakpoint, I increment manually the row value and ... > no exception :( > > Do you have an idea ? > > Thanks, > > ISession session = UnitOfWork.CurrentSession; > using (ITransaction tx = session.BeginTransaction()) > { > try > { > _repository.Save(employee); > tx.Commit(); > } > catch (NHibernate.StaleStateException) > { > tx.Rollback(); > throw new Exception("blabla"); > } > catch (NHibernate.HibernateException ex) > { > tx.Rollback(); > throw new Exception(ex.Message); > } > > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
