我遇到了一個問題,訂購了我通過ORMLite查詢的對象列表,我想通過2個單獨的列進行排序。我想以優先級最低和計數最高的順序排列。但是,好像查詢只接受最後一個orderBy而不是兩個。例如這裏有兩個查詢及其結果:ORMLite orderBy多列不工作
QueryBuilder<CategoryData, Integer> queryBuilder4 = dao.queryBuilder();
queryBuilder4.orderBy(CategoryData.FACE_COUNT_COLUMN_NAME, false);
queryBuilder4.orderBy(CategoryData.PRIORITY_COLUMN_NAME, true);
Log.d(TAG, "4 Query returns:"+ queryBuilder4.query().toString());
而且它的輸出:
name=Blues, db=158, count=3, priority=1, firstLookDbID=6
name=Greens, db=165, count=3, priority=8, firstLookDbID=9
name=Blacks, db=157, count=1, priority=0, firstLookDbID=2,...
第二個代碼塊:
QueryBuilder<CategoryData, Integer> queryBuilder5 = dao.queryBuilder();
queryBuilder5.orderBy(CategoryData.PRIORITY_COLUMN_NAME, true);
queryBuilder5.orderBy(CategoryData.FACE_COUNT_COLUMN_NAME, false);
Log.d(TAG, "5 Query returns:"+ queryBuilder5.query().toString());
而且它的輸出:
name=Blacks, db=157, count=1, priority=0, firstLookDbID=2
name=Blues, db=158, count=3, priority=1, firstLookDbID=6
...
name=Greens, db=165, count=3, priority=8, firstLookDbID=9...
注意t之間的唯一區別我查詢的訂單是orderBys。然而,他們給了我2個不同的有序集。
OH!我明白。非常感謝你 – Jeff