How to deserialize an object persisted in a db now when the object has different serialVersionUID

后端 未结 6 1952
太阳男子
太阳男子 2020-12-14 04:34

My client has an oracle data base and an object was persisted as a blob field via objOutStream.writeObject, the object now has a different serialVersionUID (eve

6条回答
  •  误落风尘
    2020-12-14 05:19

    You should be able to hack around the issue by overriding ObjectInputStream.readClassDescriptor.

    Using XMLEncoder wont actually help with version migration as the compatibility rules are much the same. Really what should probably be doing is persisting the object in a relational form with the help of an ORM tool.

    Probably the different serialVersionUIDs happened due to different synthetic members being generated by javac. Head the warnings and put serialVersionUID in.

提交回复
热议问题