本文整理了Java中org.springframework.data.domain.Sort.isSorted()
方法的一些代码示例,展示了Sort.isSorted()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sort.isSorted()
方法的具体详情如下:
包路径:org.springframework.data.domain.Sort
类名称:Sort
方法名:isSorted
暂无
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Creates a {@link TypedQuery} for the given {@link Specification} and {@link Sort}.
*
* @param spec can be {@literal null}.
* @param domainClass must not be {@literal null}.
* @param sort must not be {@literal null}.
* @return
*/
protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec, Class<S> domainClass, Sort sort) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<S> query = builder.createQuery(domainClass);
Root<S> root = applySpecificationToCriteria(spec, domainClass, query);
query.select(root);
if (sort.isSorted()) {
query.orderBy(toOrders(sort, root, builder));
}
return applyRepositoryMethodMetadata(em.createQuery(query));
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
protected KeyValueQuery<RedisOperationChain> complete(final RedisOperationChain criteria, Sort sort) {
KeyValueQuery<RedisOperationChain> query = new KeyValueQuery<>(criteria);
if (query.getCriteria() != null && !CollectionUtils.isEmpty(query.getCriteria().getSismember())
&& !CollectionUtils.isEmpty(query.getCriteria().getOrSismember()))
if (query.getCriteria().getSismember().size() == 1 && query.getCriteria().getOrSismember().size() == 1) {
query.getCriteria().getOrSismember().add(query.getCriteria().getSismember().iterator().next());
query.getCriteria().getSismember().clear();
}
if (sort.isSorted()) {
query.setSort(sort);
}
return query;
}
代码示例来源:origin: spring-projects/spring-data-mongodb
public void onCreation(PartTreeMongoQuery query) {
PartTree tree = query.getTree();
if (!tree.hasPredicate()) {
return;
}
Index index = new Index();
index.named(query.getQueryMethod().getName());
Sort sort = tree.getSort();
for (Part part : tree.getParts()) {
if (GEOSPATIAL_TYPES.contains(part.getType())) {
return;
}
String property = part.getProperty().toDotPath();
Direction order = toDirection(sort, property);
index.on(property, order);
}
// Add fixed sorting criteria to index
if (sort.isSorted()) {
for (Order order : sort) {
index.on(order.getProperty(), order.getDirection());
}
}
MongoEntityMetadata<?> metadata = query.getQueryMethod().getEntityInformation();
indexOperationsProvider.indexOps(metadata.getCollectionName()).ensureIndex(index);
LOG.debug(String.format("Created %s!", index));
}
代码示例来源:origin: apache/servicemix-bundles
public boolean isUnsorted() {
return !isSorted();
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
public void onCreation(PartTreeMongoQuery query) {
PartTree tree = query.getTree();
if (!tree.hasPredicate()) {
return;
}
Index index = new Index();
index.named(query.getQueryMethod().getName());
Sort sort = tree.getSort();
for (Part part : tree.getParts()) {
if (GEOSPATIAL_TYPES.contains(part.getType())) {
return;
}
String property = part.getProperty().toDotPath();
Direction order = toDirection(sort, property);
index.on(property, order);
}
// Add fixed sorting criteria to index
if (sort.isSorted()) {
for (Order order : sort) {
index.on(order.getProperty(), order.getDirection());
}
}
MongoEntityMetadata<?> metadata = query.getQueryMethod().getEntityInformation();
indexOperationsProvider.indexOps(metadata.getCollectionName()).ensureIndex(index);
LOG.debug(String.format("Created %s!", index));
}
代码示例来源:origin: spring-projects/spring-data-keyvalue
/**
* Add given {@link Sort}.
*
* @param sort must not be {@literal null}.
* @return
*/
public KeyValueQuery<T> orderBy(Sort sort) {
Assert.notNull(sort, "Sort must not be null!");
if (this.sort.isSorted()) {
this.sort = this.sort.and(sort);
} else {
this.sort = sort;
}
return this;
}
代码示例来源:origin: alibaba/sca-best-practice
protected <T> TypedQuery<T> getQuery(Class<T> clazz, @Nullable Specification<T> spec, Sort sort) {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<T> query = builder.createQuery(clazz);
Root<T> root = applySpecificationToCriteria(clazz, spec, query);
query.select(root);
if (sort.isSorted()) {
query.orderBy(toOrders(sort, root, builder));
}
return entityManager.createQuery(query);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Returns the current {@link Sort} or the given one if the current one is unsorted.
*
* @param sort must not be {@literal null}.
* @return
*/
default Sort getSortOr(Sort sort) {
Assert.notNull(sort, "Fallback Sort must not be null!");
return getSort().isSorted() ? getSort() : sort;
}
代码示例来源:origin: org.springframework.vault/spring-vault-core
@Override
protected KeyValueQuery<VaultQuery> complete(VaultQuery vaultQuery, Sort sort) {
KeyValueQuery<VaultQuery> query = new KeyValueQuery<>(vaultQuery);
if (sort.isSorted()) {
query.orderBy(sort);
}
return query;
}
代码示例来源:origin: spring-projects/spring-data-keyvalue
@Override
protected KeyValueQuery<SpelExpression> complete(String criteria, Sort sort) {
KeyValueQuery<SpelExpression> query = new KeyValueQuery<>(this.expression);
if (sort.isSorted()) {
query.orderBy(sort);
}
return query;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
protected KeyValueQuery<SpelExpression> complete(String criteria, Sort sort) {
KeyValueQuery<SpelExpression> query = new KeyValueQuery<>(this.expression);
if (sort.isSorted()) {
query.orderBy(sort);
}
return query;
}
代码示例来源:origin: org.springframework.data/spring-data-keyvalue
@Override
protected KeyValueQuery<SpelExpression> complete(String criteria, Sort sort) {
KeyValueQuery<SpelExpression> query = new KeyValueQuery<>(this.expression);
if (sort.isSorted()) {
query.orderBy(sort);
}
return query;
}
代码示例来源:origin: Microsoft/spring-data-cosmosdb
public DocumentQuery with(@NonNull Sort sort) {
if (sort.isSorted()) {
this.sort = sort.and(this.sort);
}
return this;
}
代码示例来源:origin: spring-projects/spring-data-r2dbc
private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunction) {
List<String> columns;
if (this.projectedFields.isEmpty()) {
columns = dataAccessStrategy.getAllColumns(typeToRead);
} else {
columns = this.projectedFields;
}
Sort sortToUse = sort.isSorted() ? dataAccessStrategy.getMappedSort(typeToRead, sort) : Sort.unsorted();
QueryOperation select = dataAccessStrategy.select(table, new LinkedHashSet<>(columns), sortToUse, page);
return execute(select.get(), mappingFunction);
}
代码示例来源:origin: org.springframework.data/spring-data-r2dbc
private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunction) {
List<String> columns;
if (this.projectedFields.isEmpty()) {
columns = dataAccessStrategy.getAllColumns(typeToRead);
} else {
columns = this.projectedFields;
}
Sort sortToUse = sort.isSorted() ? dataAccessStrategy.getMappedSort(typeToRead, sort) : Sort.unsorted();
QueryOperation select = dataAccessStrategy.select(table, new LinkedHashSet<>(columns), sortToUse, page);
return execute(select.get(), mappingFunction);
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
protected KeyValueQuery<RedisOperationChain> complete(final RedisOperationChain criteria, Sort sort) {
KeyValueQuery<RedisOperationChain> query = new KeyValueQuery<>(criteria);
if (query.getCriteria() != null && !CollectionUtils.isEmpty(query.getCriteria().getSismember())
&& !CollectionUtils.isEmpty(query.getCriteria().getOrSismember()))
if (query.getCriteria().getSismember().size() == 1 && query.getCriteria().getOrSismember().size() == 1) {
query.getCriteria().getOrSismember().add(query.getCriteria().getSismember().iterator().next());
query.getCriteria().getSismember().clear();
}
if (sort.isSorted()) {
query.setSort(sort);
}
return query;
}
代码示例来源:origin: Microsoft/spring-data-cosmosdb
@Override
public <T> Page<T> findAll(Pageable pageable, Class<T> domainClass, String collectionName) {
final DocumentQuery query = new DocumentQuery(Criteria.getInstance(CriteriaType.ALL)).with(pageable);
if (pageable.getSort().isSorted()) {
query.with(pageable.getSort());
}
return paginationQuery(query, domainClass, collectionName);
}
代码示例来源:origin: spring-projects/spring-data-keyvalue
@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
AbstractCollQuery<T, ?> query = prepareQuery(predicate);
if (pageable.isPaged() || pageable.getSort().isSorted()) {
query.offset(pageable.getOffset());
query.limit(pageable.getPageSize());
if (pageable.getSort().isSorted()) {
query.orderBy(toOrderSpecifier(pageable.getSort(), builder));
}
}
return new PageImpl<>(query.fetchResults().getResults(), pageable, count(predicate));
}
代码示例来源:origin: org.springframework.data/spring-data-keyvalue
@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
AbstractCollQuery<T, ?> query = prepareQuery(predicate);
if (pageable.isPaged() || pageable.getSort().isSorted()) {
query.offset(pageable.getOffset());
query.limit(pageable.getPageSize());
if (pageable.getSort().isSorted()) {
query.orderBy(toOrderSpecifier(pageable.getSort(), builder));
}
}
return new PageImpl<>(query.fetchResults().getResults(), pageable, count(predicate));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
AbstractCollQuery<T, ?> query = prepareQuery(predicate);
if (pageable.isPaged() || pageable.getSort().isSorted()) {
query.offset(pageable.getOffset());
query.limit(pageable.getPageSize());
if (pageable.getSort().isSorted()) {
query.orderBy(toOrderSpecifier(pageable.getSort(), builder));
}
}
return new PageImpl<>(query.fetchResults().getResults(), pageable, count(predicate));
}
内容来源于网络,如有侵权,请联系作者删除!