• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deserialization for Backward Compatibility

 
Himanshu Jhamb
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I have an object OBA that was serialized and stored in the DB. Currently, I read it from the DB, deserialize it, cast it back to the original OBA and merrily go about processing.
Now, I want to add some functionality to the OBA class... how do I ensure backward compatibility for any existing stuff that I already have in the DB?
The issue is - After I make the change to OBA, it complains about the deserialized class not compatible with the original one - gives a different serialVersionUID for this deserialized class. Its kind of logical to expect this ... but I wanna know if anyone has a solution to ensure backward compatibility.
thanks
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Love to know that myself.
If ever I make a change to a class that I've instantiated and serialized objects from, I normally have to write a small little program that deserializes the current object(s), creates an object of the new class and transfers the data, then write that new object to where ever. Not very efficient, but the only way I can get around the errors.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Himanshu,
u can use program called 'serialver' to generate a Serial VersionUID for any class and embed that in any class so that future versions are compatible..
look at here for example
regards
maulin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!