if (pageResults.isEmpty() && (feedResponse.getResponseContinuation() == null || isChangeFeed)) {
@Override public <T> Page<T> paginationQuery(DocumentQuery query, Class<T> domainClass, String collectionName) { Assert.isTrue(query.getPageable().getPageSize() > 0, "pageable should have page size larger than 0"); Assert.hasText(collectionName, "collection should not be null, empty or only whitespaces"); final Pageable pageable = query.getPageable(); final FeedOptions feedOptions = new FeedOptions(); if (pageable instanceof DocumentDbPageRequest) { feedOptions.setRequestContinuation(((DocumentDbPageRequest) pageable).getRequestContinuation()); } feedOptions.setPageSize(pageable.getPageSize()); feedOptions.setEnableCrossPartitionQuery(query.isCrossPartitionQuery(getPartitionKeyNames(domainClass))); final SqlQuerySpec sqlQuerySpec = new FindQuerySpecGenerator().generate(query); final FeedResponse<Document> response = executeQuery(sqlQuerySpec, feedOptions, collectionName); final Iterator<Document> it = response.getQueryIterator(); final List<T> result = new ArrayList<>(); for (int index = 0; it.hasNext() && index < pageable.getPageSize(); index++) { // Limit iterator as inner iterator will automatically fetch the next page final Document doc = it.next(); if (doc == null) { continue; } final T entity = mappingDocumentDbConverter.read(domainClass, doc); result.add(entity); } final DocumentDbPageRequest pageRequest = DocumentDbPageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), response.getResponseContinuation()); return new PageImpl<>(result, pageRequest, count(query, domainClass, collectionName)); }