I am creating a web service and I wondered if there was a solution to paginate all queries.
Currently I am creating overloaded methods such as findAll(int offset, int limit) etc. But I wondered if there was another solution to this which doesn’t create that much duplication of logic in the finders. I want to this at database level. Or is the solution that I came up with an OK approach?
I am creating a web service and I wondered if there was a solution
Share
I think you may want to use method overloading to avoid duplication of logic, if duplication is the primary concern.
Change all your existing
findAllmethods to support pagination as you have mentioned:Then create overloaded
findAll()method and internally call thefindAllmethods created in step 1 with default values e.g. below: