[JAVA-1319] The aggregation method is inaccurately showing type Created: 23/Jul/14  Updated: 11/Sep/19  Resolved: 25/Jul/14

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Dylan Yang Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

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



 Comments   
Comment by Jeffrey Yemin [ 25/Jul/14 ]

No problem Dylan. Good luck with your application.

Comment by Dylan Yang [ 25/Jul/14 ]

Thanks Jeff, i figured out what my problem is. Our system is using Scala and Play framework and Mongo Java driver 2.12. The problem is that i put mongo-shell-like-query jar file into our system and try to use it. This API steps over my current mongo driver, btw it is also written by Scala. That's why it throws compile errors in Scala build system, not in my regular Java test. Appreciate for your kind help.
Dylan

Comment by Jeffrey Yemin [ 25/Jul/14 ]

I suspect that you are accidentally using a previous version of the driver. I was able to compile the code you provided against 2.12, but get the same error that you did against 2.11. What build system are you using and how is it configured?

Comment by Dylan Yang [ 24/Jul/14 ]

i use the most current java driver 2.12.

Comment by Jeffrey Yemin [ 23/Jul/14 ]

What version of the driver are you using? Can you try with 2.12?

Generated at Thu Feb 08 08:54:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.