Skip to content

Commit eef1709

Browse files
BenWhiteheadkurtisvg
authored andcommitted
Add ReadOnly TransactionOptions to Datastore snippet (GoogleCloudPlatform#1321)
1 parent 4146a94 commit eef1709

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

datastore/src/test/java/com/google/datastore/snippets/ConceptsTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.google.cloud.datastore.PathElement;
3737
import com.google.cloud.datastore.ProjectionEntity;
3838
import com.google.cloud.datastore.Query;
39-
import com.google.cloud.datastore.Query.ResultType;
4039
import com.google.cloud.datastore.QueryResults;
4140
import com.google.cloud.datastore.ReadOption;
4241
import com.google.cloud.datastore.StringValue;
@@ -50,6 +49,8 @@
5049
import com.google.common.collect.ImmutableMap;
5150
import com.google.common.collect.ImmutableSet;
5251
import com.google.common.collect.Iterators;
52+
import com.google.datastore.v1.TransactionOptions;
53+
import com.google.datastore.v1.TransactionOptions.ReadOnly;
5354
import java.io.IOException;
5455
import java.util.ArrayList;
5556
import java.util.Calendar;
@@ -826,7 +827,11 @@ public void testTransactionalSingleEntityGroupReadOnly() {
826827
// [START datastore_transactional_single_entity_group_read_only]
827828
Entity taskList;
828829
QueryResults<Entity> tasks;
829-
Transaction txn = datastore.newTransaction();
830+
Transaction txn = datastore.newTransaction(
831+
TransactionOptions.newBuilder()
832+
.setReadOnly(ReadOnly.newBuilder().build())
833+
.build()
834+
);
830835
try {
831836
taskList = txn.get(taskListKey);
832837
Query<Entity> query = Query.newEntityQueryBuilder()

0 commit comments

Comments
 (0)