org.springframework.data.jpa.repository.support.Querydsl.applyPagination()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中org.springframework.data.jpa.repository.support.Querydsl.applyPagination方法的一些代码示例,展示了Querydsl.applyPagination的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Querydsl.applyPagination方法的具体详情如下:
包路径:org.springframework.data.jpa.repository.support.Querydsl
类名称:Querydsl
方法名:applyPagination

Querydsl.applyPagination介绍

[英]Applies the given Pageable to the given JPQLQuery.
[中]将给定的可分页应用于给定的JPQLQuery。

代码示例

代码示例来源:origin: spring-projects/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}

代码示例来源:origin: spring-projects/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}

代码示例来源:origin: org.springframework.data/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}

代码示例来源:origin: org.springframework.data/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-operational-metadata-jpa

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

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-operational-metadata-jpa

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

代码示例来源:origin: stackoverflow.com

public Page<CardCategoryLevel> findAll(Predicate predicate, Pageable pageable) {
  JPAQuery countQuery = createQuery(predicate);
  JPAQuery query = (JPAQuery) querydsl.applyPagination(pageable, createQuery(predicate));

代码示例来源:origin: zalando-stups/fullstop

final PageRequest fixedPage = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), fixedSort);
getQuerydsl().applyPagination(fixedPage, query);

代码示例来源:origin: metatron-app/metatron-discovery

@Override
 public Page<MetadataColumn> linkedMetadataColumns(String dictionaryId, Pageable pageable) {

  QMetadataColumn qMetadataColumn = QMetadataColumn.metadataColumn;

  JPQLQuery<MetadataColumn> query = from(qMetadataColumn).join(qMetadataColumn.metadata).fetchJoin()
                              .where(qMetadataColumn.dictionary.id.eq(dictionaryId));

  Long total = query.fetchCount();

  List<MetadataColumn> contents;
  if(total > pageable.getOffset()) {
   query = getQuerydsl().applyPagination(pageable, query);
   contents = query.fetch();
  } else {
   contents = Lists.newArrayList();
  }

  return new PageImpl<>(contents, pageable, total);
 }
}

代码示例来源:origin: metatron-app/metatron-discovery

public Page<Metadata> searchMetadatas(Metadata.SourceType sourceType, String catalogId, String tag, String nameContains,
                  String searchDateBy, DateTime from, DateTime to, Pageable pageable) {
 QMetadata qMetadata = QMetadata.metadata;
 QTagDomain qTagDomain = QTagDomain.tagDomain;
 JPQLQuery<Metadata> query;
 if(StringUtils.isNotEmpty(tag)) {
  query = from(qMetadata, qTagDomain).select(qMetadata)
    .where(qMetadata.id.eq(qTagDomain.domainId))
    .where(qTagDomain.tag.name.eq(tag));
 } else {
  query = from(qMetadata);
 }
 query.where(MetadataPredicate.searchList(sourceType, catalogId, null, nameContains, searchDateBy, from, to));
 Long total = query.fetchCount();
 List<Metadata> contents;
 if(total > pageable.getOffset()) {
  query = getQuerydsl().applyPagination(pageable, query);
  contents = query.fetch();
 } else {
  contents = Lists.newArrayList();
 }
 return new PageImpl<>(contents, pageable, total);
}

代码示例来源:origin: cheese10yun/spring-jpa-best-practices

public Page<Account> search(final AccountSearchType type, final String value, final Pageable pageable) {
  final QAccount account = QAccount.account;
  final JPQLQuery<Account> query;
  switch (type) {
    case EMAIL:
      query = from(account)
          .where(account.email.value.likeIgnoreCase(value + "%"));
      break;
    case NAME:
      query = from(account)
          .where(account.firstName.likeIgnoreCase(value + "%")
              .or(account.lastName.likeIgnoreCase(value + "%")));
      break;
    case ALL:
      query = from(account).fetchAll();
      break;
    default:
      throw new IllegalArgumentException();
  }
  final List<Account> accounts = getQuerydsl().applyPagination(pageable, query).fetch();
  return new PageImpl<>(accounts, pageable, query.fetchCount());
}

代码示例来源:origin: zalando-stups/fullstop

getQuerydsl().applyPagination(pageRequest, query);

代码示例来源:origin: metatron-app/metatron-discovery

query = getQuerydsl().applyPagination(pageable, query);
 contents = query.fetch();
} else {

相关文章