Search in sources :

Example 1 with QPageRequest

use of org.springframework.data.querydsl.QPageRequest in project kylo by Teradata.

the class QueryDslPagingSupport method findAll.

protected Page<E> findAll(JPAQuery query, Pageable pageable) {
    if (pageable == null) {
        pageable = new QPageRequest(0, Integer.MAX_VALUE);
    }
    long total = query.clone(super.getEntityManager()).fetchCount();
    JPQLQuery pagedQuery = getQuerydsl().applyPagination(pageable, query);
    List<E> content = total > pageable.getOffset() ? pagedQuery.fetch() : Collections.<E>emptyList();
    return new PageImpl<>(content, pageable, total);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) QPageRequest(org.springframework.data.querydsl.QPageRequest) JPQLQuery(com.querydsl.jpa.JPQLQuery)

Example 2 with QPageRequest

use of org.springframework.data.querydsl.QPageRequest in project kylo by Teradata.

the class QueryDslPagingSupport method findAllWithFetch.

public Page<E> findAllWithFetch(EntityPathBase<E> path, Predicate predicate, boolean distinct, Pageable pageable, QueryDslFetchJoin... joins) {
    if (pageable == null) {
        pageable = new QPageRequest(0, Integer.MAX_VALUE);
    }
    long total = createFetchQuery(path, predicate, distinct, joins).fetchCount();
    JPQLQuery pagedQuery = getQuerydsl().applyPagination(pageable, createFetchQuery(path, predicate, distinct, joins));
    List<E> content = total > pageable.getOffset() ? pagedQuery.fetch() : Collections.<E>emptyList();
    return new PageImpl<>(content, pageable, total);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) QPageRequest(org.springframework.data.querydsl.QPageRequest) JPQLQuery(com.querydsl.jpa.JPQLQuery)

Aggregations

JPQLQuery (com.querydsl.jpa.JPQLQuery)2 PageImpl (org.springframework.data.domain.PageImpl)2 QPageRequest (org.springframework.data.querydsl.QPageRequest)2