/** * Break a circular dependency caused by delete operations. * 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 deleting B, then delete A. * @param edge Edge in the dependency graph corresponding to a foreign key * constraint. This dependency is broken by nullifying the foreign key. * @param deleteUpdates Collection of update statements that are executed * before the delete operations are flushed */ private void addDeleteUpdate(Edge edge, Collection deleteUpdates) throws SQLException { PrimaryRow row; RowImpl update; ForeignKey fk; // copy where conditions into new update that nulls the fk row = (PrimaryRow) edge.getTo(); update = new PrimaryRow(row.getTable(), Row.ACTION_UPDATE, null); row.copyInto(update, true); if (edge.getUserObject() instanceof ForeignKey) { fk = (ForeignKey) edge.getUserObject(); update.setForeignKey(fk, row.getForeignKeyIO(fk), null); } else update.setNull((Column) edge.getUserObject()); deleteUpdates.add(update); }
/** * Break a circular dependency caused by delete operations. * 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 deleting B, then delete A. * @param edge Edge in the dependency graph corresponding to a foreign key * constraint. This dependency is broken by nullifying the foreign key. * @param deleteUpdates Collection of update statements that are executed * before the delete operations are flushed */ private void addDeleteUpdate(Edge edge, Collection deleteUpdates) throws SQLException { PrimaryRow row; RowImpl update; ForeignKey fk; // copy where conditions into new update that nulls the fk row = (PrimaryRow) edge.getTo(); update = new PrimaryRow(row.getTable(), Row.ACTION_UPDATE, null); row.copyInto(update, true); if (edge.getUserObject() instanceof ForeignKey) { fk = (ForeignKey) edge.getUserObject(); update.setForeignKey(fk, row.getForeignKeyIO(fk), null); } else update.setNull((Column) edge.getUserObject()); deleteUpdates.add(update); }
/** * Break a circular dependency caused by delete operations. * 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 deleting B, then delete A. * @param edge Edge in the dependency graph corresponding to a foreign key * constraint. This dependency is broken by nullifying the foreign key. * @param deleteUpdates Collection of update statements that are executed * before the delete operations are flushed */ private void addDeleteUpdate(Edge edge, Collection deleteUpdates) throws SQLException { PrimaryRow row; RowImpl update; ForeignKey fk; // copy where conditions into new update that nulls the fk row = (PrimaryRow) edge.getTo(); update = new PrimaryRow(row.getTable(), Row.ACTION_UPDATE, null); row.copyInto(update, true); if (edge.getUserObject() instanceof ForeignKey) { fk = (ForeignKey) edge.getUserObject(); update.setForeignKey(fk, row.getForeignKeyIO(fk), null); } else update.setNull((Column) edge.getUserObject()); deleteUpdates.add(update); }
/** * Break a circular dependency caused by delete operations. * 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 deleting B, then delete A. * @param edge Edge in the dependency graph corresponding to a foreign key * constraint. This dependency is broken by nullifying the foreign key. * @param deleteUpdates Collection of update statements that are executed * before the delete operations are flushed */ private void addDeleteUpdate(Edge edge, Collection deleteUpdates) throws SQLException { PrimaryRow row; RowImpl update; ForeignKey fk; // copy where conditions into new update that nulls the fk row = (PrimaryRow) edge.getTo(); update = new PrimaryRow(row.getTable(), Row.ACTION_UPDATE, null); row.copyInto(update, true); if (edge.getUserObject() instanceof ForeignKey) { fk = (ForeignKey) edge.getUserObject(); update.setForeignKey(fk, row.getForeignKeyIO(fk), null); } else update.setNull((Column) edge.getUserObject()); deleteUpdates.add(update); }
/** * Break a circular dependency caused by delete operations. * 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 deleting B, then delete A. * @param edge Edge in the dependency graph corresponding to a foreign key * constraint. This dependency is broken by nullifying the foreign key. * @param deleteUpdates Collection of update statements that are executed * before the delete operations are flushed */ private void addDeleteUpdate(Edge edge, Collection deleteUpdates) throws SQLException { PrimaryRow row; RowImpl update; ForeignKey fk; // copy where conditions into new update that nulls the fk row = (PrimaryRow) edge.getTo(); update = new PrimaryRow(row.getTable(), Row.ACTION_UPDATE, null); row.copyInto(update, true); if (edge.getUserObject() instanceof ForeignKey) { fk = (ForeignKey) edge.getUserObject(); update.setForeignKey(fk, row.getForeignKeyIO(fk), null); } else update.setNull((Column) edge.getUserObject()); deleteUpdates.add(update); }
update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), null); if (updates == null) updates = new ArrayList();
update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), null); if (updates == null) updates = new ArrayList();
update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), null); if (updates == null) updates = new ArrayList();
update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), null); if (updates == null) updates = new ArrayList();
update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), null); if (updates == null) updates = new ArrayList();
update.setForeignKey(fk, row.getForeignKeyIO(fk), row.getForeignKeySet(fk)); row.clearForeignKey(fk);
else row.copyInto(update, true); update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), sm); row.clearForeignKey(fks[i]);
update.setForeignKey(fk, row.getForeignKeyIO(fk), row.getForeignKeySet(fk)); row.clearForeignKey(fk);
update.setForeignKey(fk, row.getForeignKeyIO(fk), row.getForeignKeySet(fk)); row.clearForeignKey(fk);
update.setForeignKey(fk, row.getForeignKeyIO(fk), row.getForeignKeySet(fk)); row.clearForeignKey(fk);
else row.copyInto(update, true); update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), sm); row.clearForeignKey(fks[i]);
else row.copyInto(update, true); update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), sm); row.clearForeignKey(fks[i]);
else row.copyInto(update, true); update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), sm); row.clearForeignKey(fks[i]);
else row.copyInto(update, true); update.setForeignKey(fks[i], row.getForeignKeyIO(fks[i]), sm); row.clearForeignKey(fks[i]);
update.setForeignKey(fk, row.getForeignKeyIO(fk), row.getForeignKeySet(fk)); row.clearForeignKey(fk);