-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4
-
Component/s: Query Operations
-
Environment:Windows 7, MongoDB Java Driver v2.10.1, MongoDB v2.4.9
The following code
Test.java
MongoClient client = new MongoClient(); DB db = client.getDB("school"); DBCollection collection = db.getCollection("students"); BasicDBList list = new BasicDBList(); list.add(new BasicDBObject("$elemMatch", new BasicDBObject("type", "homework"))); BasicDBObject query = new BasicDBObject("scores", new BasicDBObject( "$all", list)); System.out.println(query); DBObject cursor = collection.findOne(new BasicDBObject(), query); System.out.println(cursor);
returns exception com.mongodb.MongoException: Unsupported projection option: $all
although if you run the command that is printed out in the shell it returns a result without error.
Steps to reproduce:
- import the attached file in MongoDB
- run the code