}
protected Iterator itr() {
final ClassMapping[] elems = _strat.getIndependentElementMappings(true);
final OpenJPAStateManager sm = assertOwner();
final JDBCStore store = getStore();
final JDBCFetchConfiguration fetch = store.getFetchConfiguration();
final Joins[] resJoins = new Joins[Math.max(1, elems.length)];
final FieldMapping fm = _strat.getFieldMapping();
Union union = store.getSQLFactory().newUnion
(Math.max(1, elems.length));
if (fetch.getSubclassFetchMode(fm.getElementMapping().
getTypeMapping()) != fetch.EAGER_JOIN)
union.abortUnion();
union.setLRS(true);
union.select(new Union.Selector() {
public void select(Select sel, int idx) {
ClassMapping elem = (elems.length == 0) ? null : elems[idx];
sel.whereForeignKey(_strat.getJoinForeignKey(elem),
sm.getObjectId(), fm.getDefiningMapping(), store);
// order before select in case we're faking union with
// multiple selects; order vals used to merge results
fm.orderLocal(sel, elem, null);
resJoins[idx] = _strat.joinElementRelation(sel.newJoins(),
elem);
fm.orderRelation(sel, elem, resJoins[idx]);
_strat.selectElement(sel, elem, store, fetch, fetch.EAGER_JOIN,
resJoins[idx]);
}
});
try {
Result res = union.execute(store, fetch);
return new ResultIterator(sm, store, fetch, res, resJoins);
} catch (SQLException se) {
throw SQLExceptions.getStore(se, store.getDBDictionary());
}
}