int index = sql.indexOf("select"); if (index == -1) { index = sql.indexOf("SELECT"); } index += 6;   StringBuffer buf = new StringBuffer(); buf.append(sql.substring(0, index)).append(" TOP(").append(start).append(",").append(end - start).append(") ").append(sql.substring(index + 1, sql.length())); sql = buf.toString();
    public NSArray objectsInRange(int start, int end) {        //uses the original fetch specification and adds a top(start,(end - start)) to the query sql        EOFetchSpecification spec = databaseDataSource().fetchSpecificationForFetch();        //sortOrderings from the WODisplayGroup is only used in Memory: painful slow...        spec.setSortOrderings(sortOrderings());        EOEditingContext ec = databaseDataSource().editingContext();        String sql = ERXEOAccessUtilities.sqlForFetchSpecificationAndEditingContext(spec, ec);                //add TOP(start, (end - start)) after the SELECT word        int index = sql.indexOf("select");        if (index == -1) {            index = sql.indexOf("SELECT");        }        index += 6;        //FIXME: this works for frontbase, might need to be adjusted for other db servers!        StringBuffer buf = new StringBuffer();        buf.append(sql.substring(0, index)).append(" TOP(").append(start).append(",").append(end - start).append(") ").append(sql.substring(index + 1, sql.length()));        sql = buf.toString();        NSDictionary hints = new NSDictionary(sql, "EOCustomQueryExpressionHintKey");        spec.setHints(hints);                return ec.objectsWithFetchSpecification(spec);    }