NHibernate FlushMode issue.


Object is being persisted even when NHibernate's flushmode is set to commit only.
Test to reproduce:
    public void ObjectPersistedWithoutTransactionCommit()
        using (UnitOfWorkScope scope = new UnitOfWorkScope())
            User user = GetValidUser();
            ISession session = NHibernateSetup.GetSession();
            session.FlushMode = FlushMode.Commit;
            IRepository<User> repository = new NCommon.Data.NHibernate.NHRepository<User>(session);
You will have a user record in your database at the end of this test. Since scope.Commit() was never called I don't think this is expected behavior.


nephesh wrote Dec 26, 2008 at 2:00 AM

Ignore the above, this was due to my misunderstanding of how to inject the repositories into my services while also using the same ISession between the UoW and the repositories. That said, I haven't figured out a way to do this without editing the NCommon code. If we could get an example on how to do this I would appreciate it. For now I'm just using my edits.


riteshrao wrote Feb 27, 2009 at 2:11 PM

See the sample web site in NCommon 0.3 release. That should provide a good example.

wrote Feb 27, 2009 at 2:11 PM

wrote Feb 13, 2013 at 11:28 PM

wrote May 16, 2013 at 3:29 AM

wrote May 16, 2013 at 3:29 AM

wrote Jun 14, 2013 at 7:26 AM