我在spring-data-mongo中遇到了一些奇怪的问题。
Query query = new Query();
query.addCriteria(Criteria.where("id").is(id));
List<Hotel> hotels = mongoOperations.find(query, Hotel.class)给出正确的结果(findById)。
然而,
MatchOperation match = Aggregation.match(Criteria.where("id").is(id));
Aggregation aggregation = Aggregation.newAggregation(match);
AggregationResults<Hotel> results = mongoOperations.aggregate(aggregation, "hotel", Hotel.class);每次都会给[]。
我有没有遗漏什么??
https://stackoverflow.com/questions/47474615
复制相似问题