PageListView和数据集加载 [英] PageListView and dataset loading

查看:101
本文介绍了PageListView和数据集加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PageableListView显示的数据集可能会变得很大,而将整个数据集作为模型保留会非常低效.是否可以仅先加载例如一组ID,然后再仅加载要在当前页面上显示的对象?我使用Wicket + Spring + Hibernate/JPA.还是在这种情况下有更好的分页方法?

The dataset I display using PageableListView can get very big and keeping the whole dataset as a model would be very inefficient. Is it possible to load for example only the set of IDs first and then load only the objects that are to be displayed on the current page? I use Wicket+Spring+Hibernate/JPA. Or is there a better approach to paging in this case?

推荐答案

(至少对我来说)处理该问题的常用方法是执行:

The usual way to deal with that (at least for me) would be to perform:

  • 第一个查询以对项目进行计数并推断要显示的页面数
  • 随后的查询使用每个页面的Query#setFirstResult(int)Query#setMaxResults(int).

Wicket,JPA,GlassFish和Java Derby或MySQL 中,作者精确地显示了如何使用Wicket和DataView而不是PageableListView(提供的示例代码)实现这种方法.

In Wicket, JPA, GlassFish and Java Derby or MySQL, the author shows precisely how to implement this approach using Wicket and a DataView instead of PageableListView (sample code provided).

这篇关于PageListView和数据集加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆