0

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.

1
  • It is better to have a pagination. You can fetch the data from the db once the user change the page. and in first case if you fetch all the data from the db at the same time means it takes more time to load. Apr 8, 2016 at 7:08

3 Answers 3

1

If you are loading the fetched data into the table means,

  1. Find the total number of records and set page count

2.On page change get the data-offset and data-limit value of the table and fetch the data from the db

  1. Change the data-offset value of the table based the page number
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.
0

It is better to have a pagination. Use index and fetch the data accordingly. you can refer this document for more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.