- Start Session
- Read object/record (presentation layer)
- Update record/object im memory (presentation layer)
- Run query to check changes valid (biz layer).
- If 4 ok commit changes inside transaction (biz layer)
- End session
This is caused by the FlushMode of the session be set to Auto. When set to auto NHibernate will sometimes flush the persistent obejct prior to performing a query.
There are a few solutions to this:
- Perform updates to object after query (not applicable in this case due to layers)
- Disconnect object prior to updating (Evict)
- Change FlushMode to Commit