title: Mongo db will not update an existing Document
body: <p>I am using java pojo's and spring MongoTemplate, I spent few hours now, trying to understand why MongoDb will not update an existing  Document
  <BR>I am able to insert documents, but not to update existing ones
  <BR>Any simple way to trace this in mongo/spring?
  <BR>I tried so far:
  <BR>Simply call save:</p>
  
  <pre><code>        person.setUpdateDate(new Date());
          mongoTemplate.save(person);
          //not working
  </code></pre>
  
  <p>call updateFirst</p>
  
  <pre><code>        mongoTemplate.updateFirst(new Query(Criteria.where("_id").is(person.getId())),
                                      Update.update("objName", "NotWorking"),Person.class);
  </code></pre>
  
  <p>Get the collection first, convert to DB Object,
  then find and modify:           </p>
  
  <pre><code>        DBCollection coll=mongoTemplate.getCollection("Person");
          DBObject mongoPerson = morphia.toDBObject(person);
          DBObject afterSave = coll.findAndModify(new BasicDBObject("id", person.getId()), mongoPerson);
          //afterSave is null
  </code></pre>
  
  <p>Try find by _id, then save:</p>
  
  <pre><code>        DBObject mongoPerson = morphia.toDBObject(person);
          Person found1 = mongoTemplate.findById(person.getId(), Person.class);
          found1.setObjName(person.getName());
          mongoTemplate.save(found1);
  </code></pre>
  
  <p>Find first, then save using "_id":  </p>
  
  <pre><code>        DBCursor found = coll.find(new BasicDBObject("_id", person.getId()));
          DBObject first = found.next();
          mongoTemplate.save(first);
  </code></pre>
  
  <p>Find first, then save using "id":   </p>
  
  <pre><code>        DBCursor found = coll.find(new BasicDBObject("id", person.getId()));
          DBObject first = found.next();
          mongoTemplate.save(first);
  </code></pre>
  
  <p>Try find and modify then save:          </p>
  
  <pre><code>        DBObject afterSave = coll.findAndModify(new BasicDBObject("id", person.getId()), mongoPerson);
          //afterSave is null
          mongoTemplate.save(person);
  </code></pre>
  
  <p>Update individual fields using query:           </p>
  
  <pre><code>        Query query = new Query();
          query.addCriteria(Criteria.where("_id").is(person.getId()));
          mongoTemplate.updateFirst(query, new Update().set("name",person.getName())
                                                       .set("desc", person.getDesc())
                                                        .set("updateDate",new Date())
                                                            , 
                                                          Person.class)
  </code></pre>