-
Notifications
You must be signed in to change notification settings - Fork 933
Description
Alexander Kovtik created an issue — 14th June 2009, 5:49:34:
Assuming that there is one Entity in the database, look at the following example
using (var s = OpenSession()) { s.FlushMode = FlushMode.Auto; using (var t = s.BeginTransaction()) { var entity = s.Load<Entity>(1); s.Delete(entity); var results = s.CreateMultiCriteria() .Add(s.CreateCriteria<Entity>()) .List(); // s.Flush() was not called, entity wasn't deleted // (IList)results<0>).Count == 1 } }
Alexander Kovtik added a comment — 14th June 2009, 5:53:48:
Test case is in attachment.
Fabio Maulo added a comment — 14th June 2009, 8:22:24:
hmmmmm.... I think this is not a issue.
Inside a transaction FlushMode.Auto should working at transaction level and the default of MsSQL should be ReadCommitted.
Alexander Kovtik added a comment — 14th June 2009, 8:40:43:
If I'll replace the call to MultiCriteria to simple hql query or criteria call, Flush() will be triggered. Moreower, it will work even with MultiQuery. So why it shouldn't work with MultiCriteria? :)
I thaught that the most common pattern for using NHibernate with web-applications called "Session per request" works in the same way
- open session with FlushMode.Auto at begin request
- open transaction at begin request
- work with data without explicitly calling Flush() - it should be triggered automatically when needed because of FlushMode.Auto
- commit transaction at end request. The results of all flushes are commited.
- close session at end request.
Did I missed something?
Fabio Maulo added a comment — 14th June 2009, 16:34:32:
About the first part of your comment we will check.
About the "common" pattern... the "common" pattern in NH is use identity as ID generator but this does not mean that it is good.