This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
The only problem there would be the changed data types. I don't think serialization can handle that, but you would have to try first to make sure. Maybe it will work if primitive types are widened, or if reference types are assignable, but I doubt it to be honest.
Rob Prime wrote:I wouldn't know right away how to solve this.
Do you think it is possible to solve this at all? If you change a String to an int in a class, you have to all intents and purposes created a different class. It is hardly going to serialise and deserialise at all.
Instead of Serializable, use Eternalizable. Then write and read a version number. In the readExternal() method, check the version number and then read only those fields that are applicable to that version. Note that the serialVersionUID needs to be hard coded so that changes in the class do not cause the UID value to change.
subject: How to deserialize persistent object if class has changed