* @param insertUpdates Collection of update statements that are executed
* after the insert/update operations are flushed
*/
private void addInsertUpdate(PrimaryRow row, Edge edge,
Collection insertUpdates) throws SQLException {
RowImpl update;
ForeignKey fk;
Column col;
// copy where conditions into new update that sets the fk
update = new PrimaryRow(row.getTable(), Row.ACTION_UPDATE, null);
if (row.getAction() == Row.ACTION_INSERT) {
if (row.getPrimaryKey() == null)
throw new InternalException(_loc.get("ref-cycle"));
update.wherePrimaryKey(row.getPrimaryKey());
} else {
// Row.ACTION_UPDATE
row.copyInto(update, true);
}
if (edge.getUserObject() instanceof ForeignKey) {
fk = (ForeignKey) edge.getUserObject();
update.setForeignKey(fk, row.getForeignKeyIO(fk),
row.getForeignKeySet(fk));
row.clearForeignKey(fk);
} else {
col = (Column) edge.getUserObject();
update.setRelationId(col, row.getRelationIdSet(col),
row.getRelationIdCallback(col));
row.clearRelationId(col);
}
insertUpdates.add(update);