How to create query with ObjectIds using java?
问题 I have set of ids like: ["51eae104c2e6b6c222ec3432", "51eae104c2e6b6c222ec3432", "51eae104c2e6b6c222ec3432"] I need to find all documents using this set of ids. BasicDBObject query = new BasicDBObject(); BasicDBList list = new BasicDBList(); ObjectId ob1 = new ObjectId("51eae100c2e6b6c222ec3431"); ObjectId ob2 = new ObjectId("51eae100c2e6b6c222ec3432"); list.add(ob1); list.add(ob2); query.append("_id", new BasicDBObject("$in", list)); This query can't find anything because it is same as { "