I have a problem.
using (var tran = repository.Session.BeginTransaction())
{
try
{
repository.Save(entity);
tran.Comit();
}
catch(Exception)
{
tran.Rollback();
throw;
}
}
using (var tran = repository.Session.BeginTransaction())
{
try
{
repository.GetById(id);
tran.Comit();
}
catch(Exception)
{
tran.Rollback();
throw;
}
}
When I try to get an entity by ID after exception and tran.rollback()
in the first using
block, I get an update exception. So NHibernate is trying to update the entity from the first using
block in the second using
block.
Why? I did the tran.Rollback()
. Must I do Session.Clear()
, too?