Sugar ORM:java.lang.IllegalStateException:无法从 CursorWindow 读取第 0 行,第 -1 列

Sugar ORM : java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow

我正在使用 SUGAR ORM,我想计算列的总和 "value" 但得到这个 错误

请帮忙。

String whereCondition ="Select unique_id, name, Sum(value), type, category_type, note, nutrient_code from NUTRIENTS group by unique_id";

List<Nutrients> nutrientsList = Nutrients.findWithQuery(Nutrients.class, whereCondition);

Sum(value) 不能直接与 SugarORM 一起使用。为此,我们需要使用 SQL 原始查询,如下所示:

 String whereCondition ="Select unique_id, name, Sum(value), type, category_type, note, nutrient_code from NUTRIENTS group by unique_id";

    Field f = null;
    try {
        f = SugarContext.getSugarContext().getClass().getDeclaredField("sugarDb");
        f.setAccessible(true);
        SugarDb db = (SugarDb) f.get(SugarContext.getSugarContext());
        Cursor cursor = db.getDB().
                rawQuery(whereCondition, null);