Skip to content

NH-1839 - MultiCriteria doesn't trigger session flush if executed after delete #988

@nhibernate-bot

Description

@nhibernate-bot

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

  1. open session with FlushMode.Auto at begin request
  2. open transaction at begin request
  3. work with data without explicitly calling Flush() - it should be triggered automatically when needed because of FlushMode.Auto
  4. commit transaction at end request. The results of all flushes are commited.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions