returnValues = SQLHelper.calculateNumberOfFields(extendingClassDescriptors,
_requestedEngine.getColumnInfoForIdentities().length,
_requestedEngine.getInfo().length, numberOfExtendLevels, this._rs);
} catch (SQLException e) {
LOG.error ("Problem calculating number of concrete fields.", e);
throw new PersistenceException("Problem calculating number of concrete fields.", e);
}
leafDescriptor = (ClassDescriptor) returnValues[0];
_engine = _requestedEngine;
if (leafDescriptor != null) {
if (!leafDescriptor.getJavaClass().getName().equals(
_requestedEngine.getDescriptor().getJavaClass().getName())) {
originalFieldNumber = ((Integer) returnValues[1]).intValue();
Persistence newEngine = null;
try {
newEngine = _requestedFactory.getPersistence(leafDescriptor);
} catch (MappingException e) {
LOG.error("Problem obtaining persistence engine for "
+ leafDescriptor.getJavaClass().getName(), e);
throw new PersistenceException("Problem obtaining persistence engine for "
+ leafDescriptor.getJavaClass().getName(), e);
}
_engine = (SQLEngine) newEngine;
}
}
}
_fields = new Object[originalFieldNumber];
// It would prove a little difficult to fetch if we don't have any rows with data left :-)
if (_resultSetDone) { return null; }
Object stamp = null;
Object[] wantedIdentity;
Object[] currentIdentity;
try {
wantedIdentity = loadSQLIdentity();
// Load first (and perhaps only) row of object data from _rs into <_fields> array.
// As we assume that we have called fetch() immediatly after nextIdentity(),
// we can be sure that it belongs to the object we want. This is probably not the
// safest programming style, but has to suffice currently :-)
loadRow(_fields, originalFieldNumber, true);
// We move forward in the ResultSet, until we see another identity or run out of rows.
while (_rs.next()) {
// Load identity from current row.
currentIdentity = loadSQLIdentity();
// Compare with wantedIdentity and determine if it is a new one.
if (identitiesEqual(wantedIdentity, currentIdentity)) {
// Load next row of object data from _rs into <_fields> array.
loadRow(_fields, originalFieldNumber, false);
} else {
// We are done with all the rows for our obj. and still have rows left.
_lastIdentity = currentIdentity;
// As stamp is never set, this function always returns null ... ???
// (Don't ask me, it was like that before I modified the code! :-)
return stamp;
}
}
// We are done with all the rows for our obj. and don't have any rows left.
_resultSetDone = true;
_lastIdentity = null;
} catch (SQLException except) {
throw new PersistenceException(Messages.format("persist.nested", except), except);
}
return null;
}