2

so my interface:

public interface SubmissionRepository extends PagingAndSortingRepository<Submission, Long> {
//all by approval phase
@RestResource(path="byApprovalPhase")
List<Submission> findByApprovalPhase(@Param("approvalPhase") ApprovalPhase approvalPhase);
//paging + sorting
@RestResource(path="byApprovalPhasePaging")
Page<Submission> findByApprovalPhase(@Param("approvalPhase") ApprovalPhase approvalPhase, Pageable pageable);
//all with sorting
@RestResource(path="byApprovalPhaseSorting")
List<Submission> findByApprovalPhase(@Param("approvalPhase") ApprovalPhase approvalPhase, Sort pageable);
}

so I get those methods in json/hal curl -v http://localhost:8080/submissions/search

....
"_links" : {
"findByApprovalPhase" : [ {
  "href" : "http://localhost:8080/submissions/search/byApprovalPhase{?approvalPhase}",
  "templated" : true
}, {
  "href" : "http://localhost:8080/submissions/search/byApprovalPhasePaging{?approvalPhase,page,size,sort}",
  "templated" : true
}, {
  "href" : "http://localhost:8080/submissions/search/byApprovalPhaseSorting{?approvalPhase}",
  "templated" : true
} ]
}
...

but curl -v http://localhost:8080/submissions/search/byApprovalPhasePaging?approvalPhase=PENDING&page=1&size=5

returns default 20 rows. Same thing with sorting - it doesnt work ( no error, just sorting has no effect). Dont know what is missed here.

//edit:

similar thing for localhost:8080/submissions - there are 14 rows total, by default it shows 20. curl -v http://localhost:8080/submissions?size=1returns 1st one, but curl -v http://localhost:8080/submissions?page=1&size=1 returns only _links to prev, next.

My repository extends PagingAndSortingRepository..

hi_my_name_is
  • 4,894
  • 3
  • 34
  • 50
  • Spring pagination starts with 0. So try with page=0 for first page.Also what version of SDR are you using? – Stackee007 Sep 17 '14 at 20:12
  • http://localhost:8080/submissions?page=0&size=1 ignores size parameter - returns all 20 ( well - 14 in this case because thats all I got ). Same with my custom method on http://localhost:8080/submissions/search/byApprovalPhasePaging?approvalPhase=PENDING&page=0&size=1. Its SDR 2.1.4. – hi_my_name_is Sep 18 '14 at 05:48
  • SDR 2.1.4 works perfectly for me with page=0&size=1. Check again – Stackee007 Sep 18 '14 at 14:23

1 Answers1

1

Silly thing.. We had to use "" around url when testing using curl.. otherwise it treat everything after & as other parameter.. more details here appending multiple querystring variables with curl

Community
  • 1
  • 1
hi_my_name_is
  • 4,894
  • 3
  • 34
  • 50