我正在阅读 MongoOperations 的 SpringData MongoDB 配置 http://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/MongoOperations.html#findOne-org.springframework.data.mongodb.core.query.Query-java.lang.Class-
仍然不明白如果多个文档满足查询,findOne 方法的行为是什么:
<T> T findOne(Query query, Class<T> entityClass)
最佳答案
根据 Mongo 文档本身,findOne()
方法将根据磁盘上元素的自然顺序返回遇到的第一个元素:
Returns one document that satisfies the specified query criteria. If multiple documents satisfy the query, this method returns the first document according to the natural order which reflects the order of documents on the disk. In capped collections, natural order is the same as insertion order. If no document satisfies the query, the method returns null
http://docs.mongodb.org/master/reference/method/db.collection.findOne/
关于java - Spring Data 中 MongoOperations 中的 findOne 方法的行为是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32616800/