* @exception DatabaseException - an error has occurred on the database
* @return an ArrayList of the resulting objects.
*/
@Override
protected Object executeObjectLevelReadQueryFromResultSet() throws DatabaseException {
AbstractSession session = this.session;
DatabasePlatform platform = session.getPlatform();
DatabaseCall call = (DatabaseCall)((CallQueryMechanism)this.queryMechanism).getCall();
call.returnCursor();
call = this.queryMechanism.cursorSelectAllRows();
Statement statement = call.getStatement();
ResultSet resultSet = call.getResult();
DatabaseAccessor accessor = (DatabaseAccessor)((List<Accessor>)this.accessors).get(0);
boolean exceptionOccured = false;
try {
ResultSetMetaData metaData = resultSet.getMetaData();
List results = new ArrayList();
ObjectBuilder builder = this.descriptor.getObjectBuilder();
while (resultSet.next()) {
results.add(builder.buildObjectFromResultSet(this, this.joinedAttributeManager, resultSet, session, accessor, metaData, platform));
}
return results;
} catch (SQLException exception) {
exceptionOccured = true;
DatabaseException commException = accessor.processExceptionForCommError(session, exception, call);
if (commException != null) {
throw commException;
}
throw DatabaseException.sqlException(exception, call, accessor, session, false);
} finally {
try {
if (resultSet != null) {
resultSet.close();
}
if (statement != null) {
accessor.releaseStatement(statement, call.getSQLString(), call, session);
}
if (accessor != null) {
session.releaseReadConnection(accessor);
}
} catch (SQLException exception) {
if (!exceptionOccured) {
//in the case of an external connection pool the connection may be null after the statement release
// if it is null we will be unable to check the connection for a comm error and