如何更改 Objectify 中的键
我有一个问题。我曾经有一个拥有 @id private String key
的实体。但现在我必须将其更改为 @id 私人长密钥
。问题是 Objectify 不让我这么做。我收到一个
IllegalStateException: Loaded Entity has name but com.XX.YYY.MyClass has no String @id
所以我不知道该怎么做。
I have a problem. I used to have an entity that had a @id private String key
. But now I have to change that to a @id private Long key
. Problem is Objectify wont let me. I get an
IllegalStateException: Loaded Entity has name but com.XX.YYY.MyClass has no String @id
So Im not sure what to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不了解 Objectify(所以希望有了解的人可以介入),但假设 Objectify 正在通过实体键必须具有名称或 id 之一的限制。一旦创建了实体,密钥就不可变。
重新输入密钥的唯一方法是
在这两种情况下,您都必须手动查找并迁移引用。
这两件事都需要细心的工作。
I'm not up on Objectify (so hopefuly someone who is can step in), but assume that Objectify is passing through the restriction that an Entity key must have exactly one of a name or an id. Once an Entity is created, the key is immutable.
The only ways to re-type a key are
In both case, you have to find and migrate references by hand.
Both of these involve careful work.