GCP 数据存储 Java API,构建具有空值的实体

GCP Datastore Java API, build an entity with null value

所以这不是 "I have a bug how to fix it" 问题,而是 "Is this really how this works?" 问题。

所以,我正在查看我的代码以将实体持久保存到数据存储区中,如果我尝试设置一个 null 属性,那么一切都会失败。我注意到有一个 setNull 但真的是这样吗?我必须在构建之前手动检查每个属性才能调用适当的 set?标准集不应该为过多的数据类型重载处理 null 吗?

这是一段代码

public void put(BatchExecution obj) {
    Key key = keyFactory.newKey(obj.getId());           
    FullEntity<Key> incBEEntity = Entity.newBuilder(key)  
        .set(BatchExecution.ID, obj.getId())
        .set(BatchExecution.NAME, obj.getName())
        .set(BatchExecution.CREATETIME, obj.getCreateTime())
        .set(BatchExecution.ELAPSEDTIME, obj.getElapsedTime()) //I break the code because elapesedTime was never set in the object
        .set(BatchExecution.STATUS, obj.getStatus().name())
        .build();
    datastore.put(incBEEntity);
  }

我是不是遗漏了什么,或者这真的是 API 的工作原理吗?

关注 github https://github.com/GoogleCloudPlatform/google-cloud-java/issues/3583

问题已关闭。