Skip to content

Commit

Permalink
Fix demo issue with keyset pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed May 20, 2017
1 parent 31f589e commit 6cb4eed
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,18 @@ public PaginatedResult<CatView> getCats(@QueryParam("page") @DefaultValue("1") i
if (firstKey == null || lastKey == null || lastPageOffset == null || lastPageSize == null) {
catSetting = EntityViewSetting.create(CatView.class, (page - 1) * pageSize, pageSize);
} else {
KeysetPage keysetPage = new KeysetPageImpl(page, pageSize, new KeysetImpl(new Serializable[]{ firstKey }), new KeysetImpl(new Serializable[]{ lastKey }));
KeysetPage keysetPage = new KeysetPageImpl(lastPageOffset, lastPageSize, new KeysetImpl(new Serializable[]{ firstKey }), new KeysetImpl(new Serializable[]{ lastKey }));
catSetting = EntityViewSetting.create(CatView.class, (page - 1) * pageSize, pageSize).withKeysetPage(keysetPage);
}

PagedList<CatView> result = evm.applySetting(catSetting, cb)
.withKeysetExtraction(true)
.getResultList();
PaginatedCriteriaBuilder<CatView> pcb = evm.applySetting(catSetting, cb)
.withKeysetExtraction(true);

String countQueryString = pcb.getPageCountQueryString();
String idQueryString = pcb.getPageIdQueryString();
String objectQueryString = pcb.getQueryString();

PagedList<CatView> result = pcb.getResultList();

return PaginatedResult.from(result, uriInfo, keyset -> keyset.getTuple()[0].toString());
}
Expand Down

0 comments on commit 6cb4eed

Please sign in to comment.