简体   繁体   中英

JpaTransactionManager doesn't rollback transaction

I use JHipster to make a simple app and write a service, code as follows:

@Service
@Transactional
public class OperateQueueActionService {
    @Transactional(rollbackFor = Throwable.class)
    public OperateQueueDTO apply(OperateQueueDTO operateQueueDTO, QueueEventType queueEventType, String deskNo) {
    StateMachine<QueueStatus, QueueEventType> stateMachine = operateQueueActionMachineService.getStateMachine();
    try {   QueueEventDTO operateQueueEventDTO = operateQueueUtils.saveQueueEvent(operateQueueDTO, queueEventType, deskNo); 
         ......in process will throw RuntimeException.
        } finally {
           stateMachine.stop();
       }
    }
}

I want the transaction to rollback and not save queueEvent , but the record is saved in the database. This is the transaction log:

[2018-07-24 12:04:51.861] [XNIO-2 task-6] WARN osslCompositeStateMachineListener -Error during stateContext java.lang.RuntimeException: 无效状态 at com.higoee.queue.state.utils.OperateQueueStateMachineLogListener.stateContext(OperateQueueStateMachineLogListener.java:58) at java.lang.Thread.run(Thread.java:745) [2018-07-24 12:04:51.871] [XNIO-2 task-6] INFO chqsuOperateQueueStateMachineLogListener -4d667539-3316-491d-a0db-240e29b0fcae状态机状态为:STATEMACHINE_STOP [2018-07-24 12:04:51.872] [XNIO-2 task-6] DEBUG osorm.jpa.JpaTransactionManager -Initiating transaction commit [2018-07-24 12:04:51.874] [XNIO-2 task-6] DEBUG osorm.jpa.JpaTransactionManager -Committing JPA transaction on EntityManager

JPA配置没有问题,弹簧状态机已捕获到StateMachineListenerAdapter中引发的异常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM