PageListView and dataset loading

好久不见. 提交于 2019-12-11 12:35:36

问题


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?


回答1:


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

  • a first query to count the items and deduce the number of pages to display
  • subsequent queries using Query#setFirstResult(int) and Query#setMaxResults(int) for each page.

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).



来源:https://stackoverflow.com/questions/3987036/pagelistview-and-dataset-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!