use of org.mongodb.morphia.Datastore in project morphia by mongodb.
the class VersionTest method testVersionsWithFindAndModify.
@Test
public void testVersionsWithFindAndModify() {
final ALongPrimitive initial = new ALongPrimitive();
Datastore ds = getDs();
ds.save(initial);
Query<ALongPrimitive> query = ds.find(ALongPrimitive.class).field("id").equal(initial.getId());
UpdateOperations<ALongPrimitive> update = ds.createUpdateOperations(ALongPrimitive.class).set("text", "some new value");
ALongPrimitive postUpdate = ds.findAndModify(query, update);
Assert.assertEquals(initial.version + 1, postUpdate.version);
}
Aggregations