String sqlString = sql.statement(); StringBuffer buf = new StringBuffer(); buf.append("select "); EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName()); NSArray attributesColumnNames = (NSArray) entity.primaryKeyAttributes().valueForKey("columnName"); for (Enumeration e = attributesColumnNames.objectEnumerator(); e.hasMoreElements();) { buf.append(e.nextElement()); if (e.hasMoreElements()) { buf.append(", "); } else { buf.append(" "); } } buf.append(sqlString.substring(sqlString.toLowerCase().indexOf("from"))); sql.setStatement(buf.toString());
    public static NSArray primaryKeyValuesInRange(EOEditingContext ec, EOFetchSpecification spec, int start, int end) {                EOSQLExpression sql = ERXEOAccessUtilities.sqlExpressionForFetchSpecification(ec, spec, start, end);        String sqlString = sql.statement();        StringBuffer buf = new StringBuffer();        buf.append("select ");        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());        NSArray attributesColumnNames = (NSArray) entity.primaryKeyAttributes().valueForKey("columnName");        for (Enumeration e = attributesColumnNames.objectEnumerator(); e.hasMoreElements();) {            buf.append(e.nextElement());            if (e.hasMoreElements()) {                buf.append(", ");            } else {                buf.append(" ");            }        }        buf.append(sqlString.substring(sqlString.toLowerCase().indexOf("from")));        sql.setStatement(buf.toString());        NSDictionary hints = new NSDictionary(sql, "EOCustomQueryExpressionHintKey");        spec.setHints(hints);        spec.setFetchesRawRows(true);        spec.setRawRowKeyPaths(entity.primaryKeyAttributeNames());        return ec.objectsWithFetchSpecification(spec);    }