@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.BeginTransactionResponse)) { return super.equals(obj); } com.google.datastore.v1.BeginTransactionResponse other = (com.google.datastore.v1.BeginTransactionResponse) obj; boolean result = true; result = result && getTransaction().equals(other.getTransaction()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; hash = (53 * hash) + getTransaction().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(com.google.datastore.v1.BeginTransactionResponse other) { if (other == com.google.datastore.v1.BeginTransactionResponse.getDefaultInstance()) return this; if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { setTransaction(other.getTransaction()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
ByteString requestTransactionId( com.google.datastore.v1.BeginTransactionRequest.Builder requestPb) { return beginTransaction(requestPb.build()).getTransaction(); }
/** * * * <pre> * The transaction identifier (always present). * </pre> * * <code>bytes transaction = 1;</code> */ public Builder clearTransaction() { transaction_ = getDefaultInstance().getTransaction(); onChanged(); return this; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.BeginTransactionResponse)) { return super.equals(obj); } com.google.datastore.v1.BeginTransactionResponse other = (com.google.datastore.v1.BeginTransactionResponse) obj; boolean result = true; result = result && getTransaction() .equals(other.getTransaction()); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.BeginTransactionResponse)) { return super.equals(obj); } com.google.datastore.v1.BeginTransactionResponse other = (com.google.datastore.v1.BeginTransactionResponse) obj; boolean result = true; result = result && getTransaction().equals(other.getTransaction()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; hash = (53 * hash) + getTransaction().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; hash = (53 * hash) + getTransaction().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
static TransactionResult build(final com.google.datastore.v1.BeginTransactionResponse response) { return new TransactionResult(response.getTransaction()); }
public Builder mergeFrom(com.google.datastore.v1.BeginTransactionResponse other) { if (other == com.google.datastore.v1.BeginTransactionResponse.getDefaultInstance()) return this; if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { setTransaction(other.getTransaction()); } onChanged(); return this; }
public Builder mergeFrom(com.google.datastore.v1.BeginTransactionResponse other) { if (other == com.google.datastore.v1.BeginTransactionResponse.getDefaultInstance()) return this; if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { setTransaction(other.getTransaction()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * * * <pre> * The transaction identifier (always present). * </pre> * * <code>bytes transaction = 1;</code> */ public Builder clearTransaction() { transaction_ = getDefaultInstance().getTransaction(); onChanged(); return this; }
ByteString requestTransactionId( com.google.datastore.v1.BeginTransactionRequest.Builder requestPb) { return beginTransaction(requestPb.build()).getTransaction(); }
/** * <pre> * The transaction identifier (always present). * </pre> * * <code>optional bytes transaction = 1;</code> */ public Builder clearTransaction() { transaction_ = getDefaultInstance().getTransaction(); onChanged(); return this; } public final Builder setUnknownFields(
ByteString tx = tres.getTransaction();
// Create an RPC request to begin a new transaction. BeginTransactionRequest.Builder treq = BeginTransactionRequest.newBuilder(); // Execute the RPC synchronously. BeginTransactionResponse tres = datastore.beginTransaction(treq.build()); // Get the transaction handle from the response. ByteString tx = tres.getTransaction(); // Create an RPC request to get entities by key. LookupRequest.Builder lreq = LookupRequest.newBuilder(); // Set the entity key with only one `path_element`: no parent. Key.Builder key = Key.newBuilder().addPathElement( Key.PathElement.newBuilder() .setKind("Trivia") .setName("hgtg")); // Add one key to the lookup request. 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; if (lresp.getFoundCount() > 0) { entity = lresp.getFound(0).getEntity(); }