NHibernate MySql transaction does not rollback
i am using nhibernate with a MySql database.
Most CRUD operations work as expected except rolling back a transaction. The following code is what i have; really straightforward, create an entity, save it, then rollback.
using (var tran = accountRepository.Session.BeginTransaction())
{
var newUser = new User();
newUser.Username = "testuser1002";
accountRepository.Session.Save(newUser);
tran.Rollback();
}
The code yield expected result in my SqlServer configuration, however, it does not work with the MySql configuration. These 开发者_如何学运维2 configurations are pretty much the same.
Make sure you are using InnoDb storage engine and not MyIsam if you need transactions. This article has some good explanations and advises.
精彩评论