Test Class to serialize is as follows:
public Class Test implements Serializable {
private static final long serialVersionUID = GENERATED_LONG_VALUE;
private int val;
private SomeClass_1 val_1;
private SomeClass_2 val_2;
private SomeClass_3 val_3;
// getter and setter for above
}
I have serialized Object of above class as BLOB in table.
Now while deserializing I just want val
and val_1
.
So I have overrided readObject() method in Test class like below.
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException {
this.val = (int) stream.readObject();
this.val_1 = (SomeClass_1) stream.readObject();
}
But after this also, It is doing stream.readObject()
for val_3
and val_4
. I am not understanding why it is happening even I am not reading val_3
and val_4
in stream.readObject()
.
P.S. I am doing serialization on server X
, While deserializing it at server Y
and class Structure is exactly same at server Y
like server X
.