如何使用Spring Data和MongoDB更新Object?
我只是做一个template.save()?
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;
}
最佳答案