p = mongoTemplate.findOne(queryObj, Person.class);
assertThat(p.getAge(), is(24));
// Now return the newly updated document when updating
p = mongoTemplate.findAndModify(queryObj, updateObj,
new FindAndModifyOptions().returnNew(true), Person.class);
assertThat(p.getAge(), is(25));
// -------------------------------------
Query queryObj2 = new Query(Criteria.where("name").is("Mary"));
p = mongoTemplate.findAndModify(
queryObj2,
updateObj,
new FindAndModifyOptions().returnNew(true).upsert(true)
.remove(false), Person.class);
assertThat(p.getName(), is("Mary"));
assertThat(p.getAge(), is(1));