Pagination in Spring Data JPA (limit and offset)

Below code should do it. I am using in my own project and tested for most cases. usage: Pageable pageable = new OffsetBasedPageRequest(offset, limit); return this.dataServices.findAllInclusive(pageable); and the source code: import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.springframework.data.domain.AbstractPageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import java.io.Serializable; /** * Created by Ergin **/ public class OffsetBasedPageRequest implements Pageable, … Read more

How to use paginator from material angular?

I’m struggling with the same here. But I can show you what I’ve got doing some research. Basically, you first start adding the page @Output event in the foo.template.ts: <md-paginator #paginator [length]=”length” [pageIndex]=”pageIndex” [pageSize]=”pageSize” [pageSizeOptions]=”[5, 10, 25, 100]” (page)=”pageEvent = getServerData($event)” > </md-paginator> And later, you have to add the pageEvent attribute in the foo.component.ts … Read more

HQL – row identifier for pagination

this is one situation where hibernate shines: typical solution with hql query. int elementsPerBlock = 10; int page = 2; return getSession().createQuery(“from SomeItems order by id asc”) .setFirstResult(elementsPerBlock * (page-1) + 1 ) .setMaxResults(elementsPerBlock) .list(); hibernate will translate this to a pattern that is understood by the database according to its sql dialect. on oracle … Read more

T-SQL Skip Take Stored Procedure

For 2005 / 2008 / 2008 R2 ;WITH cte AS ( SELECT Journals.JournalId, Journals.Year, Journals.Title, ArticleCategories.ItemText, ROW_NUMBER() OVER (ORDER BY Journals.JournalId,ArticleCategories.ItemText) AS RN FROM Journals LEFT OUTER JOIN ArticleCategories ON Journals.ArticleCategoryId = ArticleCategories.ArticleCategoryId ) SELECT JournalId, Year, Title, ItemText FROM cte WHERE RN BETWEEN 11 AND 20 For 2012 this is simpler SELECT Journals.JournalId, Journals.Year, … Read more

Handle Paging with RxJava

You could model it recursively: Observable<ApiResponse> getPageAndNext(int page) { return getResults(page) .concatMap(new Func1<ApiResponse, Observable<ApiResponse>>() { @Override public Observable<ApiResponse> call(ApiResponse response) { // Terminal case. if (response.next == null) { return Observable.just(response); } return Observable.just(response) .concatWith(getPageAndNext(response.next)); } }); } Then, to consume it, getPageAndNext(0) .concatMap(new Func1<ApiResponse, Observable<ResponseObject>>() { @Override public Observable<ResponseObject> call(ApiResponse response) { return Observable.from(response.results); … Read more