Browse Source

关闭session

dzx 1 năm trước cách đây
mục cha
commit
979fc46d6a

+ 7 - 8
src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

@@ -1293,10 +1293,6 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                     session.quietRollback();
                 }
                 throw new MyException("【表单id: " + formConfig.getFormId() + "】 提交错误, 请联系管理员!");
-            }finally {
-                for (Session session : sessionList) {
-                    session.close();
-                }
             }
 
         }
@@ -1335,6 +1331,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             for (Session session : sessionList) {
                 session.getConnection().setAutoCommit(Boolean.FALSE);
                 session.commit();
+                session.close();
             }
 
             return result;
@@ -1458,10 +1455,6 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                     session.quietRollback();
                 }
                 throw new MyException("【表单id: " + formConfig.getFormId() + "】 提交错误, 请联系管理员!");
-            }finally {
-                for (Session session : sessionList) {
-                    session.close();
-                }
             }
 
         }
@@ -1534,6 +1527,10 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             } else {
                 throw new MyException("表单提交错误, 请联系系统管理员!");
             }
+        }finally {
+            for (Session session : sessionList) {
+                session.close();
+            }
         }
 
     }
@@ -2102,6 +2099,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             for (Session session : sessionList) {
                 session.getConnection().setAutoCommit(Boolean.FALSE);
                 session.commit();
+                session.close();
             }
 
         } catch (Exception e) {
@@ -2427,6 +2425,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                 //TODO  如果审批接口 出现Can't call commit when autocommit=true 错误  也可以像这样设置解决
                 session.getConnection().setAutoCommit(false);
                 session.commit();
+                session.close();
             }
         } catch (Exception e) {
             for (Session session : sessionList) {