Forums Register Login

Serialized HashSet?

+Pie Number of slices to send: Send
If I Serialize an object, should all of the fields of the object be serialized along with the object?
My object has a member whose type is HashSet.
My object is being serialized, but when I de-serialized the object, the field that is a HashSet is not populated as expected...
+Pie Number of slices to send: Send
All of the objects within the HashSet need to be serializable, also. Just because the set is serialized doesn't mean everything within it knows how to be serialized, also.
+Pie Number of slices to send: Send
Although, if the problem is that the HashSet contains nonserializable objects, you should get a NotSerializableException, which should make the problem obvious.
Terrence - when you say "the field that is a HashSet is not populated as expected" what do you mean? Is the field null? Does it contain an empty HashSet? A HashSet with different contents? Are the contents all different, or are some the same, or what? How exactly do you know there's something wrong?
+Pie Number of slices to send: Send
That fixed it.
The object that I had in the set was not Serializable.
I added that to my object, and it works.
Thanks for your help ,
Terrence
Would you like to try a free sample? Today we are featuring tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1106 times.
Similar Threads
Using Serialize to hold login info
What serialized object looks like?
doubt about collections
How is serialization handled with transient variables defined in Collections ?
Load 20000 String Objects into Memory
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:22:40.