I am developing a gate interface for an EJB3 Java application with a MySQL database. A website basically presents forms and shows tables. For these tables, I prefer to create IDataProviders that work very well with AjaxPagingNavigation. But I have some tables that are quite large, and the IDataProvider size function becomes a little complicated to implement. I usually use a counter for a query, and this is done in most cases, but I have some large tables where the counter takes too much time (3s +). Now there are several options that I can use, but I'm not very happy with using any of them, so why am I asking anyone know an elegant solution to implement the size () function for a large table?
The first option I found on Google is to use a subquery with limited results to execute score a. But since I mostly use named queries and EJB3, it seems hacky, and it can be difficult to maintain if something changes.
The second option is to use a ListDataView and just make a limited query in the table and omit the need for a large query for counting. This solution is still my favorite, but not the most pleasant, since it (almost) always gets the maximum number of records. I also have to choose between storing this List object or re-querying the database between queries.
The last parameter I found was a fake size option. I did not implement this, but I could force the IDataProvider size () function to return something like pagesize + 1. This leads to several other problems, such as the presence of pages with page records. There are checks to catch them, but this is also messy.
Does anyone know an elegant solution to use IDataProvider at the gate to display paged tables of large database tables?
Thanks a lot, Martin
source
share