MongoDB java driver : filter by the id -


i use latest version of java driver of mongodb. unfortunately after searching not able filter _id ...

i tried lot of things :

_id id_objet = new _id(); id_objet.set$oid(idobjet);  document mydoc = collection.find(eq("_id", id_objet)).first(); 

i got bad request error grizzly ...

what proper way filter _id latest version of driver ?

thanks help

it not big deal :

document mydoc = collection.find(eq("_id", new objectid(idobjet))).first(); 

you have use objectid(id).


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -