Pagination with large number of records

I have scenario where I need to fetch large number of records from database and display in ui. I have below two possible solutions. Can you please help me selecting better one. 1. Fetch all records from database and keep it in memory and display only required number of records on ui. 2. Fetch only few records using hibernate pagination that need to be displayed to ui.

I can use display-tag library or jquery for pagination.

Thanks in advance.

Answers 1

  • Some additional notes to other answers.

    1. With display tag you can use ajax:displayTag from AjaxTags JavaScript-JSP Library to load pages via AJAX. Our team uses it intensively.
    2. This simply class can be used to specify pagination parameters for Hibernate: Pagination.
    3. Keep in mind, that in real life you will use requests with joins. It is impossible to use pagination for such kind of requests. Hibernate will load all records in memory and return paginated data for you from the memory. In such situations it will be better get paginated ids firstly and load data by ids.

Related Articles