批處理異常問(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();
}
}
循環(huán)第二次執(zhí)行批處理時(shí)會(huì)將表鎖死。



































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