本文整理汇总了Java中org.springframework.data.repository.query.ParametersParameterAccessor.getSort方法的典型用法代码示例。如果您正苦于以下问题:Java ParametersParameterAccessor.getSort方法的具体用法?Java ParametersParameterAccessor.getSort怎么用?Java ParametersParameterAccessor.getSort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.repository.query.ParametersParameterAccessor
的用法示例。
在下文中一共展示了ParametersParameterAccessor.getSort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareQuery
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
protected KeyValueQuery<?> prepareQuery(KeyValueQuery<?> instance, Object[] parameters) {
ParametersParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(),
parameters);
Object criteria = instance.getCriteria();
if (criteria instanceof SpelCriteria || criteria instanceof SpelExpression) {
SpelExpression spelExpression = getSpelExpression(criteria);
EvaluationContext context = this.evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(),
parameters);
criteria = new SpelCriteria(spelExpression, context);
}
KeyValueQuery<?> query = new KeyValueQuery(criteria);
Pageable pageable = accessor.getPageable();
Sort sort = accessor.getSort();
query.setOffset(pageable.toOptional().map(Pageable::getOffset).orElse(-1L));
if (pageable.isPaged()) {
query.setRows(pageable.getPageSize());
} else if (instance.getRows() >= 0) {
query.setRows(instance.getRows());
}
query.setSort(sort.isUnsorted() ? instance.getSort() : sort);
return query;
}
示例2: executeInternal
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入方法依赖的package包/类
private Object executeInternal(ParametersParameterAccessor accessor) {
BaseQuery<?> query = createQuery(accessor);
Class<?> projectionClass = getProjection(accessor);
if (projectionClass != null) {
ProjectionInformation pi = getQueryMethod().getFactory().getProjectionInformation(projectionClass);
query.setProjectionInformation(pi);
}
Sort sort = query.getSort();
if (sort == null) {
sort = accessor.getSort();
} else {
sort = sort.and(accessor.getSort());
}
query.setSort(sort);
if (query.getPageable() == null) {
query.setPageable(accessor.getPageable());
}
if (isModify(query)) {
throw new UnsupportedOperationException("Hibernate Search repository support is read-only!");
} else if (getQueryMethod().isSliceQuery()) {
return snowdropOperations.findSlice(query);
} else if (getQueryMethod().isPageQuery()) {
return snowdropOperations.findPageable(query);
} else if (getQueryMethod().isStreamQuery()) {
return snowdropOperations.stream(query);
} else if (getQueryMethod().isCollectionQuery()) {
return snowdropOperations.findAll(query);
} else if (isCountProjection(query)) {
return snowdropOperations.count(query);
} else if (isExistsProjection(query)) {
return (snowdropOperations.count(query) > 0);
} else if ((projectionClass != null) || getQueryMethod().isQueryForEntity()) {
return snowdropOperations.findSingle(query);
} else {
throw new IllegalArgumentException("Invalid query type.");
}
}
示例3: createQuery
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入方法依赖的package包/类
private Query<?> createQuery(Object[] values, boolean withPageSort) {
Query<?> q = QB.create(metadata);
ParametersParameterAccessor accessor = new ParametersParameterAccessor(
parameters, values);
Or or = new Or();
int index = 0;
for (GqOrPart node : tree) {
And and = new And();
for (GqPart part : node) {
PropertyPath path = part.getProperty();
if (path.getOwningType().getType() != metadata.getThisType()) {
throw new IllegalArgumentException("PathType:"
+ path.getOwningType().getType() + " metadata:"
+ metadata.getThisType());
}
String fieldName = path.getSegment();
ColumnMapping field = metadata.findField(fieldName);
PairIO<GqParameter> paramInfo = getBindParamIndex(index++,
fieldName);
Object obj = accessor.getBindableValue(paramInfo.first);
if (field != null) {
IgnoreIf ignore = paramInfo.second.getIgnoreIf();
if (ignore == null || !QueryUtils.isIgnore(ignore, obj)) {
add(and, part, field.field(), obj);
}
}
}
or.addCondition(and);
}
q.addCondition(or);
if (withPageSort) {
Sort sort = tree.getSort();
if (accessor.getSort() != null) {
sort = accessor.getSort();
}
Pageable page = accessor.getPageable();
if (page != null && page.getSort() != null) {
sort = page.getSort();
}
if (sort != null)
setSortToSpec(q, sort, metadata);
}
return q;
}