return new RowManagerImpl(false);
}
protected Collection flush(RowManager rowMgr,
PreparedStatementManager psMgr, Collection exceps) {
RowManagerImpl rmimpl = (RowManagerImpl) rowMgr;
// first take care of all secondary table deletes and 'all row' deletes
// (which are probably secondary table deletes), since no foreign
// keys ever rely on secondary table pks
flush(rmimpl.getAllRowDeletes(), psMgr);
flush(rmimpl.getSecondaryDeletes(), psMgr);
// now do any 'all row' updates
flush(rmimpl.getAllRowUpdates(), psMgr);
// analyze foreign keys
Collection<PrimaryRow> inserts = rmimpl.getInserts();
Collection<PrimaryRow> updates = rmimpl.getUpdates();
Collection<PrimaryRow> deletes = rmimpl.getDeletes();
Graph[] graphs = new Graph[2]; // insert graph, delete graph
analyzeForeignKeys(inserts, updates, deletes, rmimpl, graphs);
// flush insert graph, if any
boolean autoAssign = rmimpl.hasAutoAssignConstraints();
try {
flushGraph(graphs[0], psMgr, autoAssign);
} catch (SQLException se) {
exceps = addException(exceps, SQLExceptions.getStore(se, dict));
} catch (OpenJPAException ke) {
exceps = addException(exceps, ke);
}
// flush the rest of the inserts and updates; inserts before updates
// because some update fks might reference pks that have to be inserted
flush(inserts, psMgr);
flush(updates, psMgr);
// flush the delete graph, if any
try {
flushGraph(graphs[1], psMgr, autoAssign);
} catch (SQLException se) {
exceps = addException(exceps, SQLExceptions.getStore(se, dict));
} catch (OpenJPAException ke) {
exceps = addException(exceps, ke);
}
// put the remainder of the deletes after updates because some updates
// may be nulling fks to rows that are going to be deleted
flush(deletes, psMgr);
// take care of all secondary table inserts and updates last, since
// they may rely on previous inserts or updates, but nothing relies
// on them
flush(rmimpl.getSecondaryUpdates(), psMgr);
// flush any left over prepared statements
psMgr.flush();
return exceps;
}