Bläddra i källkod

修复手动回滚不生效的问题

欧阳劲驰 2 månader sedan
förälder
incheckning
2fae2f9f72

+ 9 - 2
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyLayerApplyThirdCopyServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
+import java.sql.Connection;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -62,6 +63,9 @@ public class GisSurveyLayerApplyThirdCopyServiceImpl implements GisSurveyLayerAp
         //开启批处理
         try (SqlSession sqlSession = mainSqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
             try {
+                //设置手动提交
+                Connection conn = sqlSession.getConnection();
+                conn.setAutoCommit(false);
                 //从session获取mapper
                 GisSurveyLayerApplyThirdCopyMapper layerApplyThirdCopyMapper = sqlSession.getMapper(GisSurveyLayerApplyThirdCopyMapper.class);
                 GisSurveyPropertyValueThirdCopyMapper propertyValueThirdCopyMapper = sqlSession.getMapper(GisSurveyPropertyValueThirdCopyMapper.class);
@@ -89,8 +93,11 @@ public class GisSurveyLayerApplyThirdCopyServiceImpl implements GisSurveyLayerAp
                     propertyValueThirdCopyMapper.save(gisSurveyPropertyValueThirdCopy);
                 }
 
-                //提交(此处会发送sql至数据库)
+                //发送sql至数据库
+                sqlSession.flushStatements();
+                //提交
                 sqlSession.commit();
+                conn.commit();
 
                 long end = System.currentTimeMillis();
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -124,7 +131,7 @@ public class GisSurveyLayerApplyThirdCopyServiceImpl implements GisSurveyLayerAp
     /**
      * 根据任务id查询
      *
-     * @param jobId       任务id
+     * @param jobId    任务id
      * @param pageable 分页请求
      * @return 采集元素副表对象
      */