の列の値を合計したい場合は、列validatedAt
がstartDate
とendDate
の間です。
だから私は結果(合計値)としてBigInteger
します。
これは私が試したものです:SpringデータMongoDBでSum SQLを使用するには?
final List<AggregationOperation> aggregationOperations = new ArrayList<>();
aggregationOperations.add(Aggregation.match(where("validatedAt").gte(startDate).lt(endDate)));
aggregationOperations.add(Aggregation.group().sum("price.value").as("total"));
final Aggregation turnoverAggregation = Aggregation.newAggregation(OrderEntity.class, aggregationOperations);
return this.mongoOperations.aggregate(turnoverAggregation, OrderEntity.class, BigInteger.class).getUniqueMappedResult();
これは動作しません。私はこのエラーがあります:
{"exception":"com.application.CommonClient$Builder$6","path":"/api/stats/dashboard","message":"Failed to instantiate java.math.BigInteger using constructor NO_CONSTRUCTOR with arguments ","error":"Internal Server Error","timestamp":1493209463953,"status":500}
何か助けてください?
何が問題なのですか?結果がありません?エラー? where条件だけでデータが返されますか? –
私は自分の質問を編集しました。 – Anna
Longを使ってみましたか? BigIntegerを期待する理由が分かりません –