java - App Engine JDO 架构更改。更新新的非空值

标签 java google-app-engine jdo

非可空类型包括 int 和 boolean。我的问题是如何通过添加这些类型的新变量的架构更改来更新已经持久存在的对象。似乎我无法检索这些对象,因为它们现在有一个 null 变量,而 null 是不允许的!

根据:http://code.google.com/appengine/docs/java/datastore/dataclasses.html#Object_Fields_and_Entity_Properties

If the field is not of a nullable value type, loading an entity without the corresponding property throws an exception. This won't happen if the entity was created from the same JDO class used to recreate the instance, but can happen if the JDO class changes, or if the entity was created using the low-level API instead of JDO.

这是否意味着无法将这些类型的变量添加到我的架构中?

最佳答案

您可以添加新属性,但它们需要能够接受空值,这意味着两件事:

  1. 您不能添加原语。您必须使用 Integer 和 Boolean,而不是 int 和 boolean。

  2. 您的代码必须为该属性准备好为 null。

关于java - App Engine JDO 架构更改。更新新的非空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2196465/

相关文章:

java - 数组的长度属性在哪里定义?

java - 实例化 RobotFixture 的新实例以传递给构造函数

java - 如何防止对单个 JDO 查询 execute() 进行多次 RPC RunQuery 调用?

java - GAE JDO 中的奇数 id 序列

java - 如何将Java程序转换为Applet?

java - apache commons httpclient 4.23表单登录问题不同请求中使用不同的 session cookie

google-app-engine - 备份 AppEngine 数据存储区的推荐策略

python - Google App Engine 上传图像 Blobstore

google-app-engine - 迁移到 Google Endpoints V2 后出现 404

java - 如果枚举值已使用 JDO 实体保存,我可以删除它吗?