如果数据库支持可滚动结果集的话可以用
[code]
ScrollableResults scrollableResults = query
.scroll(ScrollMode.SCROLL_SENSITIVE);
// ScrollableResults scrollableResults = query.scroll();
// get the total elements number
scrollableResults.last();
this.totalElements = scrollableResults.getRowNumber() + 1;
[/code]
数据量较小的话直接用
[code]
query.list().size();
[/code]
如果是海量数据的话还是用count(*)
[code]
ScrollableResults scrollableResults = query
.scroll(ScrollMode.SCROLL_SENSITIVE);
// ScrollableResults scrollableResults = query.scroll();
// get the total elements number
scrollableResults.last();
this.totalElements = scrollableResults.getRowNumber() + 1;
[/code]
数据量较小的话直接用
[code]
query.list().size();
[/code]
如果是海量数据的话还是用count(*)