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
- Export the data, fix it up outside the datastore, then clear out the datastore and reload, or
- 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.
精彩评论