Are you using 2nd level cache? What's the log output look like?  And
does it work if you do this:

try {
  ...
  // session.Flush();
  tx.Rollback()
} finally {
  session.Dispose();
  txManager.Dispose(tx);
}



On Sep 12, 7:06 am, CAM <[EMAIL PROTECTED]> wrote:
> There is no exception occurring in the test code, I'm just simulating
> the rollback. The problem is even though I do a rollback and close the
> session the objects added inside the transaction are available...
>
> Note that the underlying database is ok, it just seem to be a problem
> with the in memory session presumably its to do with what Castle is
> doing to provide its own session wrapper.
>
> // CAM
>
> On Sep 12, 10:12 am, "Ken Egozi" <[EMAIL PROTECTED]> wrote:
>
> > Im not sure if it's related, but in your code sample, if the exception occur
> > after "session.Flush();", then the finally is executed, but " tx.Rollback();
> > session.Close();" is not.
>
> > On Fri, Sep 12, 2008 at 12:05 PM, CAM <[EMAIL PROTECTED]> wrote:
>
> > > 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
>
> > --
> > Ken 
> > Egozi.http://www.kenegozi.com/bloghttp://www.musicglue.comhttp://www.castle...
--~--~---------~--~----~------------~-------~--~----~
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