Saturday, 15 June 2013

How do I replace Java's default deserialization with my own readObject call? -



How do I replace Java's default deserialization with my own readObject call? -

someone thought thought store objects in database in blob column using java's default serialization methods. construction of these objects controlled grouping , changed field type bigdecimal long, info in our database remains same. can't read objects because causes classcastexceptions.

i tried override writing own readobject method, throws streamcorruptedexception because written default writeobject method.

how create readobject phone call behave java's default one? there number of bytes can skip data?

if want read what's in database alternative them alter class again, , institute awareness you're relying on class definition when class serialized. simply implementing own readobject() phone call can't prepare this, , if class under else's command can't anyway.

if you're prepared throw away existing info have many other choices starting custom serialization, writereplace()/readresolve(), externalizable, ... or different mechanism such xml.

but if you're going have 3rd parties changing things whenever sense you're going have problems of 1 kind or another.

bigdecimal long sounds retrograde step anyway.

java deserialization

No comments:

Post a Comment