We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4461f5b commit 17b411fCopy full SHA for 17b411f
com/google/datastore/snippets/ConceptsTest.java
@@ -278,8 +278,17 @@ public void testLookup() {
278
public void testUpdate() {
279
datastore.put(testEntity);
280
// [START datastore_update]
281
- Entity task = Entity.newBuilder(datastore.get(taskKey)).set("priority", 5).build();
282
- datastore.update(task);
+ Entity task;
+ Transaction txn = datastore.newTransaction();
283
+ try {
284
+ task = Entity.newBuilder(txn.get(taskKey)).set("priority", 5).build();
285
+ txn.put(task);
286
+ txn.commit();
287
+ } finally {
288
+ if (txn.isActive()) {
289
+ txn.rollback();
290
+ }
291
292
// [END datastore_update]
293
assertEquals(task, datastore.get(taskKey));
294
}
0 commit comments