private static void deleteModel(Entity model) throws DatastoreException { BeginTransactionRequest.Builder treq = BeginTransactionRequest.newBuilder(); BeginTransactionResponse tres = datastore.beginTransaction(treq.build()); ByteString tx = tres.getTransaction(); CommitRequest.Builder request = CommitRequest.newBuilder(); request.setTransaction(tx); Entity.Builder entity = Entity.newBuilder(lock); request.getMutationBuilder().addDelete(entity.getKey()); CommitResponse response = datastore.commit(request.build()); request.clearTransaction(); }