本文介绍了MongoDB java 驱动程序:按 id 过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用最新版本的 MongoDB 的 Java 驱动程序.不幸的是,搜索后我无法通过 _id 过滤...
I use the latest version of the Java Driver of MongoDB. Unfortunately after searching I am not able to filter by an _id ...
我尝试了很多东西:
_id id_objet = new _id(); id_objet.set$oid(idobjet); Document myDoc = collection.find(eq("_id", id_objet)).first();我对 Grizzly 的请求错误...
I got a bad request error with Grizzly ...
使用最新版本的驱动程序按_id过滤的正确方法是什么?
What is the proper way to filter by _id with the latest version of the driver ?
感谢您的帮助
推荐答案终于没什么大不了的 :
It was finally not a big deal :
Document myDoc = collection.find(eq("_id", new ObjectId(idobjet))).first();您必须使用 ObjectId(id).
You have to use ObjectId(id).
更多推荐
MongoDB java 驱动程序:按 id 过滤
发布评论