MongoDB user org.springframework.data.mongodb.core.query and use findById return null

Viewed 13

I am useing java to serach smth in mongoDB,but got a problem here my java code:

query.addCriteria(where(ColumnConstants.ID).is(new ObjectId(id)))

So when debug in idea,I find this:

Query: { "_id" : { "$oid" : "63242dcac6438d000192331e" }, "orgId" : 2757, "level" : 2 }, Fields: { }, Sort: { }

So at last,mongo give me a null,but the _id is right,how can I get a true serach? And how to write java code to get what I want is

  Query: { "_id" : { ObjetId("63242dcac6438d000192331e" )}, "orgId" : 2757, "level" : 2 }, Fields: { }, Sort: { }

I already test in navicat findById must use a object package _id? Please help me to finsh this damned job thanks.

0 Answers
Related