/** * Creates a {@link Query} instance using the given {@link ConvertingParameterAccessor}. Will delegate to * {@link #createQuery(ConvertingParameterAccessor)} by default but allows customization of the count query to be * triggered. * * @param accessor must not be {@literal null}. * @return */ protected Query createCountQuery(ConvertingParameterAccessor accessor) { return applyQueryMetaAttributesWhenPresent(createQuery(accessor)); }
@Override public Object execute(Query query) { GeoResults<Object> geoResults = doExecuteQuery(query); Page<GeoResult<Object>> page = PageableExecutionUtils.getPage(geoResults.getContent(), accessor.getPageable(), () -> { Query countQuery = mongoQuery.createCountQuery(accessor); countQuery = mongoQuery.applyQueryMetaAttributesWhenPresent(countQuery); return operation.matching(countQuery).count(); }); // transform to GeoPage after applying optimization return new GeoPage<>(geoResults, accessor.getPageable(), page.getTotalElements()); } }
@Override public Object execute(Object[] parameters) { ConvertingParameterAccessor accessor = new ConvertingParameterAccessor(operations.getConverter(), new MongoParametersParameterAccessor(method, parameters)); Query query = createQuery(accessor); applyQueryMetaAttributesWhenPresent(query); query = applyAnnotatedDefaultSortIfPresent(query); ResultProcessor processor = method.getResultProcessor().withDynamicProjection(accessor); Class<?> typeToRead = processor.getReturnedType().getTypeToRead(); FindWithQuery<?> find = typeToRead == null // ? executableFind // : executableFind.as(typeToRead); MongoQueryExecution execution = getExecution(accessor, find); return processor.processResult(execution.execute(query)); }
/** * Creates a {@link Query} instance using the given {@link ConvertingParameterAccessor}. Will delegate to * {@link #createQuery(ConvertingParameterAccessor)} by default but allows customization of the count query to be * triggered. * * @param accessor must not be {@literal null}. * @return */ protected Query createCountQuery(ConvertingParameterAccessor accessor) { return applyQueryMetaAttributesWhenPresent(createQuery(accessor)); }
@Override public Object execute(Query query) { GeoResults<Object> geoResults = doExecuteQuery(query); Page<GeoResult<Object>> page = PageableExecutionUtils.getPage(geoResults.getContent(), accessor.getPageable(), () -> { Query countQuery = mongoQuery.createCountQuery(accessor); countQuery = mongoQuery.applyQueryMetaAttributesWhenPresent(countQuery); return operation.matching(countQuery).count(); }); // transform to GeoPage after applying optimization return new GeoPage<>(geoResults, accessor.getPageable(), page.getTotalElements()); } }
@Override public Object execute(Object[] parameters) { ConvertingParameterAccessor accessor = new ConvertingParameterAccessor(operations.getConverter(), new MongoParametersParameterAccessor(method, parameters)); Query query = createQuery(accessor); applyQueryMetaAttributesWhenPresent(query); query = applyAnnotatedDefaultSortIfPresent(query); ResultProcessor processor = method.getResultProcessor().withDynamicProjection(accessor); Class<?> typeToRead = processor.getReturnedType().getTypeToRead(); FindWithQuery<?> find = typeToRead == null // ? executableFind // : executableFind.as(typeToRead); MongoQueryExecution execution = getExecution(accessor, find); return processor.processResult(execution.execute(query)); }