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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations