* Analyze the given rows against the inserts, placing dependencies
* in the given graph.
*/
private Graph analyzeAgainstInserts(Collection rows, RowManagerImpl rowMgr,
Graph graph) {
PrimaryRow row;
Row row2;
ForeignKey[] fks;
Column[] cols;
for (Iterator itr = rows.iterator(); itr.hasNext();) {
row = (PrimaryRow) itr.next();
if (!row.isValid())
continue;
// check this row's fks against inserts; a logical fk to an auto-inc
// column is treated just as actual database fk because the result
// is the same: the pk row has to be inserted before the fk row
fks = row.getTable().getForeignKeys();
for (int j = 0; j < fks.length; j++) {
if (row.getForeignKeySet(fks[j]) == null)
continue;
// see if this row is dependent on another. if it's only
// depenent on itself, see if the fk is logical or deferred, in
// which case it must be an auto-inc because otherwise we
// wouldn't have recorded it
row2 = rowMgr.getRow(fks[j].getPrimaryKeyTable(),
Row.ACTION_INSERT, row.getForeignKeySet(fks[j]), false);
if (row2 != null && row2.isValid() && (row2 != row
|| fks[j].isDeferred() || fks[j].isLogical()))
graph = addEdge(graph, row, (PrimaryRow) row2, fks[j]);
}
// see if there are any relation id columns dependent on
// auto-inc objects
cols = row.getTable().getRelationIdColumns();
for (int j = 0; j < cols.length; j++) {
OpenJPAStateManager sm = row.getRelationIdSet(cols[j]);
if (sm == null)
continue;
row2 = rowMgr.getRow(getBaseTable(sm), Row.ACTION_INSERT,
sm, false);