Datastoreにデータの新規登録をする際には以下のように行います。
private static void createHoge(String id) 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(); Key.Builder key = Key.newBuilder().addPathElement( Key.PathElement.newBuilder().setKind("Hoge").setName(id)); entity.setKey(key); entity.addProperty(Property.newBuilder().setName("param").setValue( Value.newBuilder().setStringValue(id))); entity.addProperty(Property.newBuilder().setName("v").setValue( Value.newBuilder().setIntegerValue(1))); entity.addProperty(Property.newBuilder().setName("sV").setValue( Value.newBuilder().setIntegerValue(1))); request.getMutationBuilder().addInsert(entity); CommitResponse response = datastore.commit(request.build()); request.clearTransaction(); }