Transaction marked as rollback only: How do I find the cause

后端 未结 8 1657
深忆病人
深忆病人 2020-11-28 19:39

I am having issues with committing a transaction within my @Transactional method:

methodA() {
    methodB()
}

@Transactional
methodB() {
    ...
    em.pers         


        
8条回答
  •  一生所求
    2020-11-28 20:08

    Found a good explanation with solutions: https://vcfvct.wordpress.com/2016/12/15/spring-nested-transactional-rollback-only/

    1) remove the @Transacional from the nested method if it does not really require transaction control. So even it has exception, it just bubbles up and does not affect transactional stuff.

    OR:

    2) if nested method does need transaction control, make it as REQUIRE_NEW for the propagation policy that way even if throws exception and marked as rollback only, the caller will not be affected.

提交回复
热议问题