Originally posted by Ritika Agarwal:
If I have an employee object and want to store it in database, do I need to serialize employee object?
That would be one way, but not the only way, to do it.
Just one common example: serialization is often used to save and migrate user sessions in a
servlet container. Imagine you have a whole server farm with machines A, B, C, and D. Machine A handles a request, and after the request, stores the user session into a file on a shared disk using serialization. Machine C gets the next request from that user, so loads the session and services the request. It's easy, simple, and doesn't require the server to know anything about what's in the session.