greenDAO icon indicating copy to clipboard operation
greenDAO copied to clipboard

Multi-field paging query (Original: 多字段分页查询)

Open 971120zyx opened this issue 6 years ago • 1 comments

There are three fields, whether to call (1 is, 0 no), call time (timestamp Long) and add time (timestamp Long), now you need to query the paging data. It is necessary to find out the call status (value 1) in the front, and the non-call status (0). The call status is sorted in descending order by call time (Long type), and the non-calls are sorted in descending order by adding time (Long type).

Original: 有三个字段,是否呼叫(1是,0否),呼叫时间(时间戳Long)和添加时间(时间戳Long),现在需要查询分页数据。需要查出呼叫状态(值为1)的在前面,未呼叫状态(0)的再后面。呼叫状态的按呼叫时间(Long型)降序排序,没呼叫的按添加时间(Long型)降序排序。

971120zyx avatar Jul 09 '19 11:07 971120zyx

If I understand correctly what you want is like SQL GROUP BY? greenDAO is an opinionated library which sticks to an object relational mapping approach. Hence it does not support this directly.

However, there are workarounds. https://stackoverflow.com/questions/40573541/how-to-use-group-by-in-greendao https://github.com/greenrobot/greenDAO/issues/164

greenrobot-team avatar Jul 16 '19 09:07 greenrobot-team