Not sure if this is the recommended way, but I set autoflush to never and manually call both flush and commit (though I have my base repository commit call flush automatically) that way I know exactly when these things happen. After reading ayende's article I realized that is how I have been dodging this bullet as I have never seen the behavior you describe. I tend to setup transactions in test and call flush to make sure it has gone to DB but don't want it committed, then at the end of the test I rollback and no changes are persisted which works quite well.
On Oct 19, 12:23 am, Fabio Maulo <[email protected]> wrote: > your are calling Flush > > 2009/10/18 acl123 <[email protected]> > > > > > > > > > The following code demonstrates a misleading situation in which data > > is committed to the database, even though commit is never called on a > > transaction. > > > Could anyone explain why? > > > [TestFixture] > > public class TestFixture > > { > > [Test] > > public void Test() > > { > > var config = DoConfiguration(); > > > using(var factory = config.BuildSessionFactory()) > > { > > using (var session = factory.OpenSession()) > > { > > CallSessionContext.Bind(session); > > > using(new TransactionScope()) > > { > > using (session.BeginTransaction()) > > { > > var myEntity = session.CreateQuery > > ("from myEntity").List<MyEntity>()[0]; > > > myEntity.Name = "test name"; > > } > > > var myEntity2 = session.CreateQuery("from > > myEntity").List<MyEntity>()[0]; > > > myEntity2.Name = "test name"; > > > session.Flush(); > > } > > > CallSessionContext.Unbind(factory); > > } > > } > > } > > } > > -- > Fabio Maulo- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
