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

前端 未结 5 1239
谎友^
谎友^ 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:48

    The problem turned out to be that the connection was auto-committing BEFORE the transaction could be rolled back. I had to change my dataSource bean to include a defaultAutoCommit property:

    
      
      
      
      
       
    
    

提交回复
热议问题