2

I am new with Jongo and mongoDB.

I am trying to update my mongodb document with the new Java object but its not working. Is there any dependancy/versioning issue of jongo? I couldn't find any solution.

Here is my code

String query = "{userName:'"+userName+"'}";
DatabaseDetails dbDetails = collection.findOne(query).as(DatabaseDetails.class);
dbDetails.addFile("abc");
dbDetails.addFilePath("filePath");
dbDetails.addfileSize("fileZize");
//HERE IT IS NOT ALLOWING with(object) type of method
collection.update(query).with(dbDetails); 

collection is defined as a class variable of type "MongoCollection".

PROBLEM: Here it is not allowing me to use "with()" method and gives error as "The method with(String) in the type Update is not applicable for the arguments (DatabaseDetails)"

I am using 0.4 version of jongo. can anybody please help me?

zero323
  • 322,348
  • 103
  • 959
  • 935
Amit
  • 451
  • 2
  • 6
  • 19

1 Answers1

1

Try to use the merge() method :

collection.update(query).merge(dbDetails); 
Thomas
  • 1,410
  • 10
  • 24