Announcement Announcement Module
No announcement yet.
Spring Data Pagination "Page" at the service layer? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data Pagination "Page" at the service layer?

    I'm not sure how to categorize this question - it's not a really a problem, but trying to separate implementations.

    I'm using Spring Data JPA. I have my repository set up to do pagination.

    When I set up my service layer it looks something like this:
    public Page<ReturnRow> findWhatever(int iDisplayStart, int iDisplayLength, sortStuff, etc.) {...}
    It works perfectly. Spring data rocks.

    My issue is with me using Page<ReturnRow> as my return value. Page is Spring Data specific. What if I decide to switch to another DAO implementation (highly unlikely, but it's possible)? Is there a more suitable/standard 'non-implementation' specific way to return pageination information or is everyone just creating their own service layer implementation?

    Does that make any sense?

  • #2
    you can return a List if you want.


    • #3
      That's one idea, but Page also has some additional information such as how many total records exist vs. how many were returned for this page, how many total pages, etc. I ended up just using the Page.