开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜