开发者

How to change keys in Objectify

I have a problem. I used to have an entity that had a @id private String key . But now I have to change t开发者_如何学Chat 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.


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

  1. Export the data, fix it up outside the datastore, then clear out the datastore and reload, or
  2. Create and populate a parallel set of Entities of a new kind, migrating corresponding data from the old entity to the new.

In both case, you have to find and migrate references by hand.

Both of these involve careful work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜