title: How do I update Object with Spring Data and MongoDB?
body: <p>How do I update Object with Spring Data and MongoDB?</p>
  
  <p>do I just do a template.save()?</p>
  
  <pre><code>  public Person update( String id, String Name ) 
      {
          logger.debug("Retrieving an existing person");
          // Find an entry where pid matches the id
  
          Query query = new Query(where("pid").is(id));
          // Execute the query and find one matching entry
          Person person = mongoTemplate.findOne("mycollection", query, Person.class);
  
          person.setName(name);
          /**
          * How do I update the database
          */
  
          return person;
      }
  </code></pre>