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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -