BasicDBObject fieldsObject=new BasicDBObject();
#设定返回字段
fieldsObject.put("name", true);
fieldsObject.put("sex", true);
fieldsObject.put("age", true);
#构建查询
Query query = new BasicQuery(new BasicDBObject(), fieldsObject);
#设定查询的条件
Criteria criteria = Criteria.where(TableMapData.Mongo.FIELD.CATEGORY).is(2);
query.addCriteria(criteria);
网友评论