Spring Ibatis DAO 구현 클래스에서 트랜잭션을 작성하는 방법.Spring ibatis의 DAO 클래스에서 트랜잭션을 작성하는 방법
일괄 처리 update.But에 다음 코드를 사용하고 있습니다. 200 레코드를 업데이트하는 데 10 초 이상 걸립니다. Google에서 검색 한 결과이 일괄 업데이트에서 트랜잭션을 구현하면 작업 속도가 빨라진다는 것을 알았습니다.
내 일괄 업데이트 코드 (클래스 SensorValueLastBeanDAOImpl에서)이 같다
public int processBatchUpdate(
final List<SensorValueLastBean> sensorValueLast) {
Integer updateCount = 0;
try {
updateCount = (Integer) getSqlMapClientTemplate().execute(
new SqlMapClientCallback<Object>() {
public Object doInSqlMapClient(SqlMapExecutor executor)
throws SQLException {
executor.startBatch();
Iterator<SensorValueLastBean> iter = sensorValueLast
.iterator();
while (iter.hasNext()) {
executor.update(
"sensor_values_last.ibatorgenerated_updateByPrimaryKeySelective",
iter.next());
}
executor.executeBatch();
return new Integer(executor.executeBatch());
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
난 getSqlMapClient().의 startTransaction()이 함수는 같은 에러가 표시되고 사용할 때 아래
com.ibatis.sqlmap.engine.impl.SqlMapSession에서 com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.startTransaction (SqlMapExecutorDelegate.java:684)
에서 java.lang.NullPointerException이 어떤 트랜잭션 관리자가 없기 때문에 Impl.startTransaction (SqlMapSessionImpl.java:164) com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.startTransaction에서
(SqlMapClientImpl.java:140는)