ㄓㄤㄑㄧㄤ

spring-data-mongodb查询结果返回指定字段

方法1

 

DBObject dbObject = new BasicDBObject();

dbObject.put("status", 1);

DBObject fieldObject = new BasicDBObject();

fieldObject.put("catalogName", true);

fieldObject.put("_id", true);

Query query = new BasicQuery(dbObject, fieldObject);

return MongoPagebleUtil.queryAndPagable(query, pageable, getMongoOperations(), ForeCatalog.class);

 

 

方法2

 

@Query(value = "{'status':?0 }", fields = "{ '_id' : 1, 'catalogName' : 1}")

List<ForeCatalog> findAllForeCatalogIdAndName(String status);

posted @ 2017-04-12 10:46  ㄓㄤㄑㄧㄤ  阅读(9335)  评论(0编辑  收藏  举报
哈哈,页脚部分。