Spring Transaction propagation REQUIRED, REQUIRES_NEW

后端 未结 3 667
梦谈多话
梦谈多话 2021-01-07 06:08

in following code method doService1() update correct sql but doService2() sql has some issue , but when i call doService() it has to c

3条回答
  •  余生分开走
    2021-01-07 06:11

    I had the same problem earlier and it was solved here : Strange behaviour with @Transactional(propagation=Propagation.REQUIRES_NEW)

    Using default setting, there won't be any new transaction proxy created when you call doService2() from the same class, as a result your annotation is not user.

    To avoid this issue you can put doService2() in another class or use aspectJ for transaction by declaring it like this :

    Best solution will depend on your application. (The second one here seems more appropriate)

提交回复
热议问题