No rollback only for transaction when exception occurs in submethod

后端 未结 2 1454
心在旅途
心在旅途 2020-12-18 05:39

I\'m using Hibernate + spring + @Transactional annotations to handle transactions in my application.

Transaction manager is declared as follows:

2条回答
  •  失恋的感觉
    2020-12-18 06:10

    Create another annotation, e.g. @NoRollbackTransactional, something like:

    @Transactional(noRollbackFor = RuntimeException.class)
    public @interface NoRollbackTransactional {
    }
    

    And use this on your methods. On the other hand I agree with Donal's comment, you should revise your transaction scopes, imho it is generally not a good idea to call @Transactional from another @Transactional.

提交回复
热议问题