You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Yves-Marie LAINÉ <ym...@gmail.com> on 2017/03/14 14:02:14 UTC

Is there a good way to use Spring Data Pageable queries with DataProvider ?

Hi,

Some months ago I tried to use Spring Data Pageable repository queries in a
DataTable. Spring Data pageable methods  take a PageRequest object that
carry all the required information for paging (int page, int size,
Direction direction, String... sortProprties), execute the count and the
select query and return a Page object that contains the page elements, the
total pages and the total elements. In basic cases Spring manage the count
query and sorting from the select query : That's quite handy.

Unfortunately I didn't manage to take advantage of this when used in a
DataProvider. I was thinking to create a generic "SpringDataProvider" but I
faced the problem that the size() method is called first and at this
point had no access to the page request informations. So I came back to the
standard way and coded 2 methods for the count and the retrieval.

But having a generic SpringDataProvider that only require to overload a
method that provide a PageRequest and return a Page could be really useful
in many case, IMHO.

Maybe I missed something. So, that's why I'm wondering if anybody managed
to do it in a nice way ?


Regards,
Yves-Marie LAINÉ