0
我在使用createCriteria()
構建的Grails中查詢。我如何強制對結果執行排序,然後將偏移量應用於最大約束。在查詢偏移量和最大值之前強制排序
代碼:
def history = Termin.createCriteria().list([max:10, offset:offset]) {
and{
//some query constraints
}
order('id', 'desc')
}
這可能會做同樣的:
def history = Termin.createCriteria().list([max:10, offset:offset,order:'desc',sort:'id']) {
and{
//some query constraints
}
}
該數據庫PostgreSQL的7.5,內置的查詢看起來是這樣的:
select
something
from
somewhere
left outer join
something
on something
left outer join
something
on something
left outer join
something
on something
where
(
something
)
order by
this_.th_id desc limit ? offset ?
在我的情況下令僅10個結果不是整個結果... – Jacob
然後,你需要提供更多的信息。女巫數據庫你使用?生成的查詢是什麼? –
更新的問題.... – Jacob