I have a simple Java class that I need to serialize to store as a value in an RDBMS or key value store. A class is simply a collection of properties of simple types (native types or Maps / lists of native types). The problem is that the class will most likely change over time (probably: adding new properties is less likely, but still possible: renaming the property, changing the type of the property, deleting the property).
I would like to be able to gracefully handle changes in the version of the class. In particular, when an attempt is made to de-serialize an instance from an older version, I would like to be able to specify some kind of handler to control the transition of the old instance to the latest version.
I do not think Java-based serialization is appropriate here. Before trying to overturn my own solution, I wonder if anyone knows about existing libraries that can help? I know a ton of alternative serialization methods for Java, but I'm specifically looking for something that will allow me to gracefully handle changes to the class definition over time.
Edit:
For what it was worth, I ended up working with the protocol buffer ( http://code.google.com/p/protobuf/ ), because it is flexible for adding and renaming fields, while on a less code snippet I have to support (in regarding Java custom serialization using readObject / writeObject).
source share