* @param updateList HashMappedList
* @return int
*/
int update(Session session, Table table, HashMappedList updateList) {
HashSet path = session.sessionContext.getConstraintPath();
HashMappedList tableUpdateList =
session.sessionContext.getTableUpdateList();
// set identity column where null and check columns
for (int i = 0; i < updateList.size(); i++) {
Row row = (Row) updateList.getKey(i);
Object[] data = (Object[]) updateList.get(i);
/**
* @todo 1.9.0 - make optional using database property - this means the identity column can be set to null to force
* creation of a new identity value
*/
table.setIdentityColumn(session, data);
if (table.triggerLists[Trigger.UPDATE_BEFORE].length != 0) {
table.fireBeforeTriggers(session, Trigger.UPDATE_BEFORE,
row.getData(), data, updateColumnMap);
}
table.enforceRowConstraints(session, data);
}
if (table.isView) {
return updateList.size();
}
// perform check/cascade operations
if (session.database.isReferentialIntegrity()) {
for (int i = 0; i < updateList.size(); i++) {
Object[] data = (Object[]) updateList.get(i);
Row row = (Row) updateList.getKey(i);
checkCascadeUpdate(session, table, tableUpdateList, row, data,
updateColumnMap, null, path);
}
}
// merge any triggered change to this table with the update list
HashMappedList triggeredList =
(HashMappedList) tableUpdateList.get(table);
if (triggeredList != null) {
for (int i = 0; i < triggeredList.size(); i++) {
Row row = (Row) triggeredList.getKey(i);
Object[] data = (Object[]) triggeredList.get(i);
mergeKeepUpdate(session, updateList, updateColumnMap,
table.colTypes, row, data);
}
triggeredList.clear();
}
// update lists - main list last
for (int i = 0; i < tableUpdateList.size(); i++) {
Table targetTable = (Table) tableUpdateList.getKey(i);
HashMappedList updateListT =
(HashMappedList) tableUpdateList.get(i);
targetTable.updateRowSet(session, updateListT, null, true);
updateListT.clear();
}
table.updateRowSet(session, updateList, updateColumnMap, false);
path.clear();
return updateList.size();
}