首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >搜索id时Aggregation.match()不起作用

搜索id时Aggregation.match()不起作用
EN

Stack Overflow用户
提问于 2017-11-24 21:45:31
回答 0查看 633关注 0票数 0

我在spring-data-mongo中遇到了一些奇怪的问题。

代码语言:javascript
复制
Query query = new Query();
query.addCriteria(Criteria.where("id").is(id));
List<Hotel> hotels = mongoOperations.find(query, Hotel.class)

给出正确的结果(findById)。

然而,

代码语言:javascript
复制
MatchOperation match = Aggregation.match(Criteria.where("id").is(id));
Aggregation aggregation = Aggregation.newAggregation(match);
AggregationResults<Hotel> results = mongoOperations.aggregate(aggregation, "hotel", Hotel.class);

每次都会给[]

我有没有遗漏什么??

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47474615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档