My GWT app is deployed on Google App Engine for Java. I have persisted instances of a class in the app engine datastore. Now I want to move that class to a different package, but it leads to problems in deserializing the existing objec开发者_如何学Pythonts.
So, is there a way I can move the class to a new package? I don't mind updating the existing objects if that helps me achieve my goal.
Thanks.
This is how I would move my.package.Clazz to my.new.package.Clazz. The basic idea is to do the migration via a third "temporary" class (TempClazz in this case):
create new class my.package.TempClazz (do NOT simply rename Clazz)
create a helper method that will read all existing Clazz entities from the datastore, then copy the data into the new TempClazz instance and store the TempClazz entities in the datastore.
now deploy to GAE and run the helper method to copy your Clazz entities to TempClazz entities.
if that worked. Delete Clazz-entities.
next, basically repeat the process, except that this time you actually refactor my.package.Clazz into the new package my.new.package.Clazz. So at this point you will have two classes: my.package.TempClazz and my.new.package.Clazz.
all that's left to do is again to read TempClazz from the datastore and copy each into a Clazz-entity.
Pretty involved. Maybe someone knows an easier way?
精彩评论