lreq.addKey(key);
// Set the transaction, so we get a consistent snapshot of the
// entity at the time the transaction started.
lreq.getReadOptionsBuilder().setTransaction(tx);
// Execute the RPC and get the response.
LookupResponse lresp = datastore.lookup(lreq.build());
// Create an RPC request to commit the transaction.
CommitRequest.Builder creq = CommitRequest.newBuilder();
// Set the transaction to commit.
creq.setTransaction(tx);
Entity entity;