I'm having an odd problem while using the NHibernate facility and
testing the transactional rollbacks.

This is the senario:

- OpenSession from ISessionManager
- Get an Entity

- Start a transaction using ITransactionManager
- Add a few new Entities
- call session.Flush
- Exception occurs...
- call Rollback
- Close the session.
- Dispose of Transaction.

- Now to verify the rollback I get another session using OpenSession
from ISessionManager
- Get one of the Entities that was rolledback...

The problem is that it still exists in the session???

I realize that Castle is pooling sessions for me, but I've explicitly
closed the session? Whats going on?

Heres the code:


      ISessionManager sessionManager =
container.Resolve<ISessionManager>();

      var product1 = new Product() { Code = "ZTRANS1", Description =
"Product Trans1" };
      var product2 = new Product() { Code = "ZTRANS2", Description =
"Product Trans2" };

      // Open the session outside of the transaction...
      ISession session = sessionManager.OpenSession();

      var getProductfirst = session.Get<Product>(product1.Id);
      ITransactionManager txManager =
container.Resolve<ITransactionManager>();
      Castle.Services.Transaction.ITransaction tx =
txManager.CreateTransaction(TransactionMode.Requires,
IsolationMode.ReadCommitted);

      try
      {
        tx.Begin();
        session.SaveOrUpdate(product1);
        session.SaveOrUpdate(product2);
        session.Flush();
        tx.Rollback();
        session.Close();
      }
      finally {
        txManager.Dispose(tx);
      }

      session = sessionManager.OpenSession();
      var getProduct1 = session.Get<Product>(product1.Id);
      // FAILS this assert...
      Assert.IsNull(getProduct1);
      var getProduct2 = session.Get<Product>(product2.Id);
      Assert.IsNull(getProduct2);


This is in RC3

thanks

// CAM
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to