![](/img/trans.png)
[英]How to fix convertion error using mongorepository with pageable
[英]SpringDataMongo MongoRepository pageable not sorted with geo-spatial method
我在MongoRepository中使用地理空间方法从Pageable排序时遇到问题
使用以下代码,当requestVo.page
为0时,我能够检索第一个requestVo.per_page
记录。但是,列表未按标题排序。
我注意到的另一件事是,相同的PageRequest
对象能够通过photoRepository.findAll
给我排序的可分页列表。 任何帮助表示赞赏!
LinkedList<Photo> photos= new LinkedList<Photo>();
PageRequest request = new PageRequest(requestVo.page, requestVo.per_page,Direction.ASC,"title");
for (GeoResult<Photo> photoResult : photoRepository.findByLocationNear(point, distance,request).getContent()) {
photos.add(photoResult.getContent());
}
return photos;
事实证明, GeoResult
正在阻止排序。 当我只返回照片集时,工作完美。
LinkedList<Photo> photos= new LinkedList<Photo>();
PageRequest request = new PageRequest(requestVo.page, requestVo.per_page,Direction.ASC,"title");
for (Photo photoResult : photoRepository.findByLocationNear(point, distance,request)) {
photos.add(photoResult);
}
return photos;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.