0
votes

We just moved from JDO to Objectify in our GAE Datastore processing.
Now we want to split one table (ok, one kind) into main and archive ones.
So we need two classes to represent the two kinds, the classes have the exact same instance variables (= entity properties).
The obvious solution for that is to have one base class with all the instance variables and two subclasses that will have the @Entity annotation.
The other solution is to have the archive class as the subclass of the main one.

Did anyone encounter such a problem and has expeirence to share?

1

1 Answers

0
votes

Assuming the 'archive' is to hold old data that is no longer live that you may need to look at later for historical or reporting reasons I would choose option 2, which is two classes with the same instance variables.

A few reasons:

  • This allows you to migrate your active 'schema' and retain old data without needing to migrate existing archive records or worry about removed fields
  • you can index different fields which allows you to manage datastore read/write costs more effectively
  • you can add additional meta information (such as archive dates, expiration dates etc) which allow you to manage your archive with a different lifecycle. This may be important depending on how much data you end up archiving