columnMap.get(primaryKeyName),
rsh);
if (columnMapTemp == null) {
conn.rollback();
throw new ControllerException("GenericController: Cannot find record.");
}
Date oldDate = (java.util.Date) columnMap.get("date_updated");
Date newDate = (java.util.Date) columnMapTemp.get("date_updated");
if (!oldDate.equals(newDate)) {
conn.rollback();
throw new UpdaterException();
// Signal that record has already been changed
}
sql = "update " + tableName;
String parameter = null;
String columnName = null;
List columnNameList = null;
List paramList = new ArrayList();
// Iterate over columns
Set columnSet = columnMapTemp.keySet();
Iterator iterator = columnSet.iterator();
int i = 0;
while (iterator.hasNext()) {
columnName = (String) iterator.next();
if (columnName.equals("date_updated")) {
parameter = "CURRENT_TIMESTAMP";
} else {
parameter = "?";
paramList.add(columnMap.get(columnName));
}
if (i++ == 0) {
sql += " set " + columnName + " = " + parameter;
} else {
sql += " ," + columnName + " = " + parameter;
}
}
sql += " where (" + primaryKeyName + "=?)";
paramList.add(columnMap.get(primaryKeyName));
// Add primaryKey value to paramList
int result = queryRunner.update(sql, paramList.toArray());
if (result == 0) {
conn.rollback();
} else {
conn.commit();
}
return result;
} catch (SQLException se) {
log.warning("SQL Exception: " + se.getMessage());
try {
conn.rollback();
} catch (SQLException se2) {
log.warning("SQL Exception: " + se2.getMessage());
throw new ControllerException(se2);
}
throw new ControllerException(se);
} finally {
try {
DbUtils.close(conn);
} catch (SQLException se3) {
log.warning("SQL Exception: " + se3.getMessage());
throw new ControllerException(se3);
}
}
}