@Override public Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType) { EvaluationContext evaluationContext = evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(), runtimeParameters); String parsedStatement = this.queryParser.doParse(parser, evaluationContext, false); String orderByPart = ""; String limitByPart = ""; Sort sort = accessor.getSort(); if (sort.isSorted()) { com.couchbase.client.java.query.dsl.Sort[] cbSorts = N1qlUtils.createSort(sort, getCouchbaseOperations().getConverter()); orderByPart = " " + new DefaultOrderByPath(null).orderBy(cbSorts).toString(); } if (queryMethod.isPageQuery()) { Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); limitByPart = " " + new DefaultLimitPath(null).limit(pageable.getPageSize()) .offset(Math.toIntExact(pageable.getOffset())).toString(); } else if (queryMethod.isSliceQuery()) { Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); limitByPart = " " + new DefaultLimitPath(null).limit(pageable.getPageSize() + 1) .offset(Math.toIntExact(pageable.getOffset())).toString(); } return N1qlQuery.simple(parsedStatement + orderByPart + limitByPart).statement(); }
@Override public Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType) { EvaluationContext evaluationContext = evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(), runtimeParameters); String parsedStatement = this.queryParser.doParse(parser, evaluationContext, false); String orderByPart = ""; String limitByPart = ""; Sort sort = accessor.getSort(); if (sort.isSorted()) { com.couchbase.client.java.query.dsl.Sort[] cbSorts = N1qlUtils.createSort(sort, getCouchbaseOperations().getConverter()); orderByPart = " " + new DefaultOrderByPath(null).orderBy(cbSorts).toString(); } if (queryMethod.isPageQuery()) { Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); limitByPart = " " + new DefaultLimitPath(null).limit(pageable.getPageSize()) .offset(Math.toIntExact(pageable.getOffset())).toString(); } else if (queryMethod.isSliceQuery()) { Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); limitByPart = " " + new DefaultLimitPath(null).limit(pageable.getPageSize() + 1) .offset(Math.toIntExact(pageable.getOffset())).toString(); } return N1qlQuery.simple(parsedStatement + orderByPart + limitByPart).statement(); }
private static Statement get(String bucket, String[] documents, int firstResult, int maxResult) { boolean hasFistResult = firstResult > 0; boolean hasMaxResult = maxResult > 0; if (hasFistResult && hasMaxResult) { return select(documents) .from(i(bucket)) .limit(maxResult) .offset(firstResult); } else if (hasFistResult) { return select(documents).from(i(bucket)).offset(firstResult); } else if (hasMaxResult) { return select(documents).from(i(bucket)).limit(maxResult); } return select(documents).from(i(bucket)); }
Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); return selectFromWhereOrderBy.limit(pageable.getPageSize()).offset(Math.toIntExact(pageable.getOffset())); } else if (queryMethod.isSliceQuery() && accessor.getPageable().isPaged()) { Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); return selectFromWhereOrderBy.limit(pageable.getPageSize() + 1).offset(Math.toIntExact(pageable.getOffset())); } else if (partTree.isLimiting()) { return selectFromWhereOrderBy.limit(partTree.getMaxResults());
Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); return selectFromWhereOrderBy.limit(pageable.getPageSize()).offset(Math.toIntExact(pageable.getOffset())); } else if (queryMethod.isSliceQuery() && accessor.getPageable().isPaged()) { Pageable pageable = accessor.getPageable(); Assert.notNull(pageable, "Pageable must not be null!"); return selectFromWhereOrderBy.limit(pageable.getPageSize() + 1).offset(Math.toIntExact(pageable.getOffset())); } else if (partTree.isLimiting()) { return selectFromWhereOrderBy.limit(partTree.getMaxResults());
Statement pageStatement = limitPath.limit(pageable.getPageSize()).offset(Math.toIntExact(pageable.getOffset()));
Statement pageStatement = limitPath.limit(pageable.getPageSize()).offset(Math.toIntExact(pageable.getOffset()));
private static Statement get(String bucket, String[] documents, int firstResult, int maxResult, Sort[] sorts) { boolean hasFistResult = firstResult > 0; boolean hasMaxResult = maxResult > 0; if (hasFistResult && hasMaxResult) { return select(documents) .from(i(bucket)) .orderBy(sorts) .limit(maxResult) .offset(firstResult); } else if (hasFistResult) { return select(documents).from(i(bucket)).orderBy(sorts).offset(firstResult); } else if (hasMaxResult) { return select(documents).from(i(bucket)).orderBy(sorts).limit(maxResult); } return select(documents).from(i(bucket)).orderBy(sorts); }
private static Statement get(String bucket, String[] documents, int firstResult, int maxResult, Expression condition) { boolean hasFistResult = firstResult > 0; boolean hasMaxResult = maxResult > 0; if (hasFistResult && hasMaxResult) { return select(documents).from(i(bucket)) .where(condition) .limit(maxResult) .offset(firstResult); } else if (hasFistResult) { return select(documents).from(i(bucket)) .where(condition) .offset(firstResult); } else if (hasMaxResult) { return select(documents).from(i(bucket)).where(condition) .limit(maxResult); } return select(documents).from(i(bucket)).where(condition); }
private static Statement get(String bucket, String[] documents, int firstResult, int maxResult, Sort[] sorts, Expression condition) { boolean hasFistResult = firstResult > 0; boolean hasMaxResult = maxResult > 0; if (hasFistResult && hasMaxResult) { return select(documents).from(i(bucket)) .where(condition) .orderBy(sorts) .limit(maxResult) .offset(firstResult); } else if (hasFistResult) { return select(documents).from(i(bucket)) .where(condition) .orderBy(sorts) .offset(firstResult); } else if (hasMaxResult) { return select(documents).from(i(bucket)).where(condition) .orderBy(sorts) .limit(maxResult); } return select(documents).from(i(bucket)).where(condition).orderBy(sorts); }