int updateSuccessCnt = _dict.getBatchUpdateCount(ps);
Object failed = null;
List batchedRows = getBatchedRows();
for (int i = 0; i < count.length; i++) {
cnt = count[i];
RowImpl row = (RowImpl) batchedRows.get(batchedRowsBaseIndex + i);
failed = row.getFailedObject();
switch (cnt) {
case Statement.EXECUTE_FAILED: // -3
if (failed != null || row.getAction() == Row.ACTION_UPDATE)
_exceptions.add(new OptimisticException(failed));
else if (row.getAction() == Row.ACTION_INSERT)
throw new SQLException(_loc.get(
"update-failed-no-failed-obj",
String.valueOf(count[i]),
row.getSQL(_dict)).getMessage());
break;
case Statement.SUCCESS_NO_INFO: // -2
if (_dict.reportsSuccessNoInfoOnBatchUpdates &&
updateSuccessCnt != count.length) {
// Oracle batching specifics:
// treat update/delete of SUCCESS_NO_INFO as failed case
// because:
// 1. transaction should be rolled back.
// 2. if DataCache is enabled, objects in
// cache should be removed.
if (failed != null)
_exceptions.add(new OptimisticException(failed));
else if (row.getAction() == Row.ACTION_INSERT)
throw new SQLException(_loc.get(
"update-failed-no-failed-obj",
String.valueOf(count[i]),
row.getSQL(_dict)).getMessage());
}
if (_log.isTraceEnabled())
_log.trace(_loc.get("batch_update_info",
String.valueOf(cnt),
row.getSQL(_dict)).getMessage());
break;
case 0: // no row is inserted, treats it as failed
// case
logSQLWarnings(ps);
if (failed != null)
_exceptions.add(new OptimisticException(failed));
else if (row.getAction() == Row.ACTION_INSERT)
throw new SQLException(_loc.get(
"update-failed-no-failed-obj",
String.valueOf(count[i]),
row.getSQL(_dict)).getMessage());
}
}
}