2016-04-22 5 views
0

このコードをJavaに変換するにはどうすればよいですか?どのようにJavaで集約フレームワークを使用するには?だから、Listを使用ドキュメントとmongoアグリゲーションを使用してmongoシェルコードをjavaコードに変換する方法

db.collection.aggregate([ 
    { "$project": { 
     "TOTAL_EMPLOYEE_SALARY": { 
      "$sum": "$employees.EMP_SALARY" 
     } 
    }} 
]) 
+1

あなたが追加することができます質問するエラー? – Schore

+0

実際には、私はこの行を書くことができません:AggregationOutput output = coll.aggregate(update);それはList <?にキャスト引数 'update'を要求しています。 BSONを拡張する> – dev777

答えて

1

Document update = new Document("$project",new Document("TOTAL_EMPLOYEE_SALARY",new Document("$sum","$employees.EMP_SALARY"))); 
AggregationOutput output = coll.aggregate(update); // throwing some error in eclipse 

私のmongoシェルコード:誰もが私のJavaコード...

を私を助けてくださいすることができ

List<Document> pipeline = Arrays.<Document>asList(
    new Document("$project", 
     new Document("TOTAL_EMPLOYEE_SALARY",new Document("$sum","$employees.EMP_SALARY")) 
    ) 
); 

AggregationOutput output = coll.aggregate(pipeline); 
関連する問題