Andy O
unread,Feb 9, 2012, 12:27:50 PM2/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
I think I might be going a bit insane staring at this for a while, so
coming here to get set straight. Here's what I'm seeing:
When NHibernate participates in a distributed transaction (eg
TransactionScope) and the NHibernate transaction commits, but the
TransactionScope rolls back, the 2nd level cache gets out of sync (it
has cached the data from the NHibernate transaction). Is this
expected? Is there a way to configure NHibernate to get around this?
If it's expected, that's fine, I can just deal w/ it rather than
trying to force it to work.
Here's a bit of a contrived example but hopefully makes the point:
using (var scope = new TransactionScope()
{
using (var session = NHibernateSessionFactory.OpenSession())
using (var transaction = session.BeginTransaction())
{
var thing = session.Get<Thing>(id);
thing.Prop = true;
transaction.Commit();
}
// no scope.Complete so will rollback
}
using (var session = NHibernateSessionFactory.OpenSession())
using (var transaction = session.BeginTransaction())
{
var thing = session.Get<Thing>(id);
Assert.IsFalse(thing.Prop); // <-- Prop is true!
}
Thanks