Annotation @Transactional. How to rollback?

后端 未结 4 1937
长情又很酷
长情又很酷 2020-11-28 02:53

I used this annotation successfully for a Dao class. And rollback works for tests.

But now I need to rollback real code, not just tests. There are special annotatio

4条回答
  •  有刺的猬
    2020-11-28 03:04

    For me rollbackFor was not enough, so I had to put this and it works as expected:

    @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
    

    I hope it helps :-)

提交回复
热议问题