Change from asList () to Arrays.asList ()
Instead of writing Arrays.asList (), you specified asList (). Therefore, the compiler is looking for the asList () method, which is NOT available.
Check out the code below:
iterable = mongoDatabase.getCollection("restaurants").find( new Document("$and", Arrays.asList(abc, updatedDocumentTypeOne)));
For your above request, you can program as shown below:
Document price1 = new BasicDBObject("price",0.99); Document price2 = new BasicDBObject("price",1.99); BasicDBList or_first = new BasicDBList(); or_first.add(price1); or_first.add(price2); DBObject query = new BasicDBObject("$or", or_first); boolean val = true; Document sale = new BasicDBObject("sale",val); Document qty = new BasicDBObject("qty", new BasicDocument("$lt",20)); BasicDBList or_second = new BasicDBList(); or_second.add(sale); or_second.add(qty); DBObject query = new BasicDBObject("$or", or_second); BasicDBList and_op = new BasicDBList(); and_op.add(or_first); and_op.add(or_second); iterable = mongoDatabase.getCollection("restaurants").find( new Document("$and", and_op ));
source share