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

后端 未结 8 1672
深忆病人
深忆病人 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:11

    Look for exceptions being thrown and caught in the ... sections of your code. Runtime and rollbacking application exceptions cause rollback when thrown out of a business method even if caught on some other place.

    You can use context to find out whether the transaction is marked for rollback.

    @Resource
    private SessionContext context;
    
    context.getRollbackOnly();
    

提交回复
热议问题