Mongo spring 查询指定字段


DBCollection coll = mongo.getCollection(OrgHeatEntity.class.getAnnotation(Document.class).collection());


DBObject query = new BasicDBObject();


query.put("organizationId", new BasicDBObject("$ne", null));


 


DBObject projection = new BasicDBObject();


projection.put("article", 1);


 


DBCursor cursor = coll.find(query, projection).skip(skip).limit(limit);


 


while (cursor.hasNext()) {


DBObject obj = cursor.next();


logger.info(" 字段的值  :{}", obj.get("article"));


}

 

 

posted @ 2015-11-03 17:07  wind90  阅读(659)  评论(0编辑  收藏  举报