You will always have memory problems when Java code moves / copies a whole dataset of data (e.g. RDBMS) into Java memory, and then sorts and filters directly in Java memory using Java code. It will be even worse if you even save it in the session area of a web application.
The most effective approach to memory is to allow the database to perform the task for which it is intended. The SQL language prompts you to sort under each ORDER BY WHERE , the WHERE to filter, and certain DB vendor specific LIMIT/OFFSET clauses / subqueries / functions to return only a subset of records based on firstrow and rowcount or lastrow. That way, you only get the dataset in the Java memory that should actually be displayed.
There is no standard JSF component that does just that. This will always require a complete dataset in the Java memory, as filtering and sorting must be done using pure Java code or Javascripts. JSF does not know anything about SQL, you need to provide a custom implementation of javax.faces.model.DataModel for datatable and / or control / management, which is at the data access level. You can get a lot of new ideas / ideas and find a launch example in this article . You can also find examples of the necessary SQL queries in this JSP-addressed answer , which I posted here.
Good luck.
source share