Search in sources :

Example 1 with JPQLQuery

use of com.querydsl.jpa.JPQLQuery 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 JPQLQuery

use of com.querydsl.jpa.JPQLQuery in project kylo by Teradata.

the class QueryDslPagingSupport method createFetchCountQuery.

private JPQLQuery createFetchCountQuery(EntityPathBase<E> path, Predicate predicate, boolean distinct) {
    JPQLQuery query = null;
    if (distinct) {
        query = from(path).distinct();
    } else {
        query = from(path);
    }
    query.where(predicate);
    return query;
}
Also used : JPQLQuery(com.querydsl.jpa.JPQLQuery)

Example 3 with JPQLQuery

use of com.querydsl.jpa.JPQLQuery in project kylo by Teradata.

the class QueryDslPagingSupport method createFetchQuery.

private JPQLQuery createFetchQuery(EntityPathBase<E> path, Predicate predicate, boolean distinct, QueryDslFetchJoin... joins) {
    JPQLQuery query = null;
    if (distinct) {
        query = from(path).distinct();
    } else {
        query = from(path);
    }
    for (QueryDslFetchJoin joinDescriptor : joins) {
        join(joinDescriptor, query);
    }
    query.where(predicate);
    return query;
}
Also used : JPQLQuery(com.querydsl.jpa.JPQLQuery)

Example 4 with JPQLQuery

use of com.querydsl.jpa.JPQLQuery in project kylo by Teradata.

the class JpaBatchJobExecutionProvider method findAllForFeed.

private Page<? extends BatchJobExecution> findAllForFeed(String feedName, List<SearchCriteria> filters, Pageable pageable) {
    QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    QJpaOpsManagerFeed checkDataFeed = new QJpaOpsManagerFeed("checkDataFeed");
    QJpaBatchJobInstance jobInstance = QJpaBatchJobInstance.jpaBatchJobInstance;
    JPQLQuery checkFeedQuery = JPAExpressions.select(checkDataFeed.id).from(feed).join(feed.checkDataFeeds, checkDataFeed).where(feed.name.eq(feedName));
    JPAQuery query = factory.select(jobExecution).from(jobExecution).join(jobExecution.jobInstance, jobInstance).join(jobInstance.feed, feed).where((feed.name.eq(feedName).or(feed.id.in(checkFeedQuery))).and(GenericQueryDslFilter.buildFilter(jobExecution, filters).and(augment(feed.id)))).fetchAll();
    pageable = CommonFilterTranslations.resolveSortFilters(jobExecution, pageable);
    return findAll(query, pageable);
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) JPQLQuery(com.querydsl.jpa.JPQLQuery) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 5 with JPQLQuery

use of com.querydsl.jpa.JPQLQuery 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)5 PageImpl (org.springframework.data.domain.PageImpl)2 QPageRequest (org.springframework.data.querydsl.QPageRequest)2 JPAQuery (com.querydsl.jpa.impl.JPAQuery)1 QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)1