Как отобразить результат массива из агрегатной функции в mongodb весной - PullRequest
0 голосов
/ 14 ноября 2018
GroupOperation operation = Aggregation.group(
  DataAccessConstants.DEPT_ID, ServiceConstants.DEPT_NAME);
AggregationOptions options= Aggregation.newAggregationOptions().allowDiskUse(true)
   .cursor(new BasicDBObject()).build();
Aggregation aggregation = Aggregation.newAggregation(operation).withOptions(options);
AggregationResults<DeptList> result = mongoTemplate.aggregate(aggregation,
    DepartmentVendorBrandFlattened.class,
    DeptList.class);

Но после выполнения result.getMappingResult для List я получаю нулевое значение.

Вот мой pojo

class DepList{
    private String depId;
    private String depDescription;
} 

соответствующий запрос монго:

db.departmentVendorBrandFlattened.aggregate([
  {$group : { _id : {deptId:"$deptId",depName: "$deptName"} }}
])

соответствующий результат выборки

[
 { "_id" : { "deptId" : "903", "depName" : "EC MISSES ACTIVEWEAR" } },
 { "_id" : { "deptId" : "229", "depName" : "CLASSIC BRAS" } }
]
...