There was an error while loading. Please reload this page.
1 parent d3bce79 commit c44f17aCopy full SHA for c44f17a
samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java
@@ -297,8 +297,17 @@ public void testLookup() {
297
public void testUpdate() {
298
datastore.put(testEntity);
299
// [START datastore_update]
300
- Entity task = Entity.newBuilder(datastore.get(taskKey)).set("priority", 5).build();
301
- datastore.update(task);
+ Entity task;
+ Transaction txn = datastore.newTransaction();
302
+ try {
303
+ task = Entity.newBuilder(txn.get(taskKey)).set("priority", 5).build();
304
+ txn.put(task);
305
+ txn.commit();
306
+ } finally {
307
+ if (txn.isActive()) {
308
+ txn.rollback();
309
+ }
310
311
// [END datastore_update]
312
assertEquals(task, datastore.get(taskKey));
313
}
0 commit comments