@Override protected Object statementValue() { return statement().toString(); }
/** * Create a new {@link N1qlQuery} with a plain un-parameterized {@link Statement}. * * @param statement the {@link Statement} to execute */ public static SimpleN1qlQuery simple(Statement statement) { return new SimpleN1qlQuery(statement, null); }
@Override public String toString() { final StringBuilder sb = new StringBuilder("SimpleN1qlQuery{"); sb.append("statement=").append(statement().toString()); sb.append('}'); return sb.toString(); } }
/** * Create a new {@link N1qlQuery} with a plain un-parameterized {@link Statement} and * custom query parameters. * * @param statement the {@link Statement} to execute * @param params the {@link N1qlParams query parameters}. */ public static SimpleN1qlQuery simple(Statement statement, N1qlParams params) { return new SimpleN1qlQuery(statement, params); }
@Override protected Statement getCount(ParameterAccessor accessor, Object[] runtimeParameters) { EvaluationContext evaluationContext = evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(), runtimeParameters); String parsedStatement = this.queryParser.doParse(parser, evaluationContext, true); return N1qlQuery.simple(parsedStatement).statement(); }
@Override protected Statement getCount(ParameterAccessor accessor, Object[] runtimeParameters) { EvaluationContext evaluationContext = evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(), runtimeParameters); String parsedStatement = this.queryParser.doParse(parser, evaluationContext, true); return N1qlQuery.simple(parsedStatement).statement(); }
@Override public Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType) { EvaluationContext evaluationContext = evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(), runtimeParameters); String parsedStatement = queryParser.doParse(parser, evaluationContext, false); return N1qlQuery.simple(parsedStatement).statement(); }
@Override public Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType) { EvaluationContext evaluationContext = evaluationContextProvider.getEvaluationContext(getQueryMethod().getParameters(), runtimeParameters); String parsedStatement = queryParser.doParse(parser, evaluationContext, false); return N1qlQuery.simple(parsedStatement).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(); }
@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(); }