다량의 인서트와 업데이트 할때 유용하다.


SqlMapClient client = getSqlMapClient();
try{
client.startTransaction(); //선언해죠야하낟.
client.startBatch();
for (int i = 0; i < listDeptIDs.size(); i++) {
Object res = getSqlMapClientTemplate().queryForObject("select-role-dept", params); // 객체있는지 판단
   //System.out.println("res : " + res + ", " + deptid + " : " + rid);
   if (res == null || Integer.parseInt("" + res) <= 0) {
    client.insert("insert-role-dept", params); // 인서트할 쿼리를 넣는다.
   }
}
client.executeBatch();
} catch (Exception e) {
   e.printStackTrace();
   return false;
  } finally {
   try {
    client.endTransaction(); // 종료 확실히
   } catch (Exception e) {
    e.printStackTrace();
    return false;
   }
  }

잘사용하자.

펌 - http://naucika.tistory.com/63