隨筆 - 32, 文章 - 1, 評(píng)論 - 5, 引用 - 0
          數(shù)據(jù)加載中……

          批處理異常問(wèn)題

          ibatis 批處理唯一性異常,執(zhí)行到事務(wù)結(jié)束。

          循環(huán)第二次執(zhí)行批處理時(shí)會(huì)將表鎖死。

          SqlMapClient smc = this.getSqlMapClient();
                  
          int index = 0;
                  
          try {
                      smc.startTransaction();
                      smc.startBatch();
                      
                      TCuBillfileChecks check 
          = new TCuBillfileChecks();
                      check.setTaskname(taskName);
                      
          for (int i = 0; i < recordList.size(); i++{
                          Record record 
          = recordList.get(i);
                          Object    custInfo 
          = pojoFactory.generatePojo(taskName, billMonth, record);
                          smc.insert(taskName 
          + ".insert_custinfo", custInfo);
                          
          if (index ++ > batchNum) {// 記錄斷點(diǎn)
                              check.setBillname(record.getAttribute("Source_FileName"));
                              check.setFilenum(Integer.parseInt(record.getAttribute(
          "RowNum")));
                              smc.update(
          "T_CU_BILLFILE_CHECKS.updateByPrimaryKey", check);
                              smc.executeBatch();
                              index 
          = 0;
                          }

                      }


                      check.setBillname(recordList.get(recordList.size() 
          - 1).getAttribute("Source_FileName"));
                      check.setFilenum(Integer.parseInt(recordList.get(recordList.size() 
          - 1).getAttribute("RowNum")));
                      smc.update(
          "T_CU_BILLFILE_CHECKS.updateByPrimaryKey", check);
                      smc.executeBatch();
                  }
           catch (Exception e) {
                      e.printStackTrace();
                  }
           finally {
                      
          try {
                          smc.commitTransaction();
                          smc.endTransaction();
                      }
           catch (Exception e) {
                          e.printStackTrace();
                      }

                  }

          posted on 2010-12-17 17:51 colorfire 閱讀(397) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 洛阳市| 赫章县| 股票| 军事| 井冈山市| 通州区| 察雅县| 藁城市| 岳西县| 宜春市| 内江市| 北海市| 江北区| 阿巴嘎旗| 綦江县| 乌什县| 武清区| 安庆市| 依兰县| 新昌县| 东辽县| 洛扎县| 海南省| 垦利县| 温宿县| 延津县| 托里县| 广丰县| 宜兰市| 德清县| 长葛市| 余庆县| 涟水县| 崇左市| 甘肃省| 明星| 渭源县| 沈丘县| 铜鼓县| 樟树市| 赣榆县|