Why are transactions not rolling back when using SpringJUnit4ClassRunner/MySQL/Spring/Hibernate

前端 未结 5 1250
谎友^
谎友^ 2021-02-06 16:04

I am doing unit testing and I expect that all data committed to the MySQL database will be rolled back... but this isn\'t the case. The data is being committed, even though my

5条回答
  •  被撕碎了的回忆
    2021-02-06 16:49

    Another way to fix your problem:

    Instead of using:

    org.hibernate.dialect.MySQLDialect
    

    , which creates a MyISAM table by default, hence not supporting transactions

    Try using

    org.hibernate.dialect.MySQLInnoDBDialect
    

    , which creates InnoDB tables, and thus supports transactions.

提交回复
热议问题