Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1319

The aggregation method is inaccurately showing type

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Java, Scala spec test, Play framework, osx

    Description

          mongoClient = new MongoClient(new MongoClientURI(uri));
          // Set the desired Database
          DB mDB = mongoClient.getDB(db);
          DBCollection collection = mDB.getCollection("objectstore");
          BasicDBObject mQuery = new BasicDBObject("data.vars",new     BasicDBObject("$exists",true));
      // create our pipeline operations, first with the $match
                  DBObject match = new BasicDBObject("$match", new BasicDBObject("data.vars", new BasicDBObject("$exists",true)));
       
                  // build the $projection operation
                  DBObject pFields = new BasicDBObject("_id", 1);
                  pFields.put("unitValueMid","$data.vars.unitValueMid");
                  DBObject project = new BasicDBObject("$project", pFields );
       
                  // run aggregation
                  List<DBObject> pipeline = Arrays.asList(match, project);
                  AggregationOutput output = collection.aggregate(pipeline);

      When i run my spec test call this code, it throws the compiler errors,

      [error] /Users/dylan/projects/connectors/app/io/point/storageconnectors/MongoDBConnector.java:754: error: method aggregate in class DBCollection cannot be applied to given types;
      [error]                 AggregationOutput output = collection.aggregate(pipeline);
      [error]                                                      ^
      [error]   required: DBObject,DBObject[]
      [error]   found: List<DBObject>
      [error]   reason: actual argument List<DBObject> cannot be converted to DBObject by method invocation conversion
      [error] 1 error
      [error] (compile:compile) javac returned nonzero exit code
      [error] Total time: 4 s, completed Jul 23, 2014 3:36:33 PM

      Attachments

        Activity

          People

            Unassigned Unassigned
            astray1988 Dylan Yang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: