private static Object __aggregateFunctionWithQualifierAndAggregateAttribute(EODatabaseContext databaseContext, EOEditingContext ec, String entityName, EOQualifier qualifier, EOAttribute aggregateAttribute) {
EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
EOSQLExpressionFactory sqlFactory = databaseContext.adaptorContext().adaptor().expressionFactory();
EOQualifier schemaBasedQualifier = entity.schemaBasedQualifier(qualifier);
EOFetchSpecification fetchSpec = new EOFetchSpecification(entity.name(), schemaBasedQualifier, null);
fetchSpec.setFetchesRawRows(true);
if (sqlFactory == null) {
/* if there is no expression factory we have no choice but to fetch */