How to restart transactions on deadlock/lock-timeout in Spring?

后端 未结 4 1520
野趣味
野趣味 2020-12-29 04:16

What is the best practice on implementing a transaction restart upon deadlock or lock timeout exceptions when using Spring (specifically the Spring recommended approach: dec

4条回答
  •  盖世英雄少女心
    2020-12-29 05:04

    I had the same question several years ago and ended up writing my own solution as an AOP aspect, which ends up looking like this in your code:

      @RetryTransaction
      @Transactional
      public void doSomething() {
          ....
      }
    

提交回复
热议问题