开发者

NHibernate MySql transaction does not rollback

开发者 https://www.devze.com 2023-03-19 08:08 出处:网络
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

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

精彩评论

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