If a class has a reference to another class, all the references must be Serializable otherwise serialization process will not be performed. In such case, NotSerializableException is thrown at runtime.
Since Address is not Serializable, we are getting NotSerializableException while serializing the instance of Employee class.
How to fix the Serialization in the case of Association?
Using the transient keyword:
In case the class refers to non-serializable objects and these objects should not be serialized, then, you can declare these objects as transient. Once a field of a class is declared as transient, then, it is ignored by the serializable runtime.
Using the static keyword:
In serialization, static variables are not serialized, so during deserialization, static variable value will load the class.
Make it a Serializable object:
All the objects within an object must be Serializable.