boolean autoAssign)
throws SQLException {
if (graph == null)
return;
DepthFirstAnalysis dfa = newDepthFirstAnalysis(graph, autoAssign);
Collection insertUpdates = new LinkedList();
Collection deleteUpdates = new LinkedList();
boolean recalculate;
// Handle circular constraints:
// - if deleted row A has a ciricular fk to deleted row B,
// then use an update statement to null A's fk to B before flushing,
// and then flush
// - if inserted row A has a circular fk to updated/inserted row B,
// then null the fk in the B row object, then flush,
// and after flushing, use an update to set the fk back to A
// Depending on where circular dependencies are broken, the
// topological order of the graph nodes has to be re-calculated.
recalculate = resolveCycles(graph, dfa.getEdges(Edge.TYPE_BACK),
deleteUpdates, insertUpdates);
recalculate |= resolveCycles(graph, dfa.getEdges(Edge.TYPE_FORWARD),
deleteUpdates, insertUpdates);
if (recalculate) {
dfa = recalculateDepthFirstAnalysis(graph, autoAssign);
}
// flush delete updates to null fks, then all rows in order, then
// the insert updates to set circular fk values
flush(deleteUpdates, psMgr);
Collection nodes = dfa.getSortedNodes();
for (Iterator itr = nodes.iterator(); itr.hasNext();)
psMgr.flush((RowImpl) itr.next());
flush(insertUpdates, psMgr);
}