Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should one maintain serialized objects?

I am creating a Serializable object descriptor that will store important state data for a non- Serailizable entity. How do I keep the old descriptors valid across application upgrades? I was thinking of opening all of the known previous state (on upgrade) and prompt the states to upgrade themselves. Maybe via a:

void onUpgrade(int oldVersion, int newVersion, int updateFlags);

but I don't know if this is a good methodology for serializable maintenance.

like image 977
ahodder Avatar asked Mar 08 '26 16:03

ahodder


1 Answers

I would suggest another form for your external representation. Serialized objects are hard to keep compatible as you already noted. The easiest thing to do would be to annotate your object with jaxb annotations and then use Jaxb to read/write it.

like image 142
Bill Avatar answered Mar 10 '26 07:03

Bill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!