qq_36859539 2018-12-18 14:37 采纳率: 100%
浏览 2306
已采纳

spring下activiti事务无法回滚?

1.spring下的service方法editApply层加了@Transactional(readOnly=false),这个方法下调用了工作流的 taskService.complete "a" 和另外一个applyService.updateClaimByTaskHistory(task.getId()) "b" ;顺序是a的方法在前,b方法在后;b方法报错后,前面执行过的工作流无法回滚。

2.工作流的配置文件已经配置过spring的事务管理

3.试过 Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);的方法’

        this.taskService.complete(repayApply.getTaskId(),map);
                Task task = this.taskService.createTaskQuery()
                        .executionId(searchRepayApply.getExecutionId()).active().singleResult();
                if(task!=null){
                    searchRepayApply.setProcessTask(task.getName());
                    this.applyService.updateClaimByTaskHistory(task.getId());
                }
                else{
                    searchRepayApply.setProcessTask("申请处理完毕");
                }

                save(searchRepayApply);

spring-context-activiti.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
    default-lazy-init="true">

    <description>Activiti Configuration</description>

    <!-- 加载配置属性文件 -->
    <context:property-placeholder ignore-unresolvable="true" location="classpath:jeesite.properties" />

    <!-- Activiti begin -->
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <property name="dataSource" ref="dataSource" />
        <property name="transactionManager" ref="transactionManager" />
<!--        <property name="deploymentResources" value="classpath*:/act/deployments/**/*.bar"/> -->
        <property name="databaseSchemaUpdate" value="true" />
        <property name="jobExecutorActivate" value="false" />
        <property name="history" value="full" />
        <property name="processDefinitionCacheLimit" value="10"/>

        <!-- UUID作为主键生成策略 -->
        <property name="idGenerator" ref="idGen" />

        <!-- 生成流程图的字体 -->
        <property name="activityFontName" value="${activiti.diagram.activityFontName}"/>
        <property name="labelFontName" value="${activiti.diagram.labelFontName}"/>

        <!-- 自定义用户权限 -->
<!--         <property name="customSessionFactories">  -->
<!--             <list> -->
<!--                <bean class="com.thinkgem.jeesite.modules.act.service.ext.ActUserEntityServiceFactory"/> -->
<!--                <bean class="com.thinkgem.jeesite.modules.act.service.ext.ActGroupEntityServiceFactory"/> -->
<!--             </list> -->
<!--        </property> -->

    </bean>

    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    </bean>

    <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
    <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
    <bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
    <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
    <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
    <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
    <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
    <!-- Activiti end -->

</beans>
  • 写回答

3条回答

  • 社会复仇者 2018-12-18 06:46
    关注

    1 看配置文件是否配置上了事物,或者有配置特殊规则
    2 方法内报错要抛出异常,如果你自己捕获了就不回滚了
    3 表必须是innoDB
    建议你打断点,执行完a以后看数据库有没有落地数据,如果已经落地了就是配置没生效

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示