Search code examples
javajakarta-eejava-ee-6

What's the purpose of extending Java serializable class?


Possible Duplicate:
Why does a class implements Serializable interface?

I'm using a tutorial found here: http://www.objectdb.com/tutorial/jpa/eclipse/ee/entity

I'm wondering why this class extends Serializable? I've read the description of this class and I don't understand the importance of serialVersionUID and why it's necessary for my model.


Solution

  • It doesn't extend a class - it implements the Serializable interface, which is basically just a marker interface to say "I'm fine to be serialized".

    The idea is to be able to transparently serialize instances of the class - potentially for caching or other purposes, I'm not sure in this case. The serialVersionUID field is just part of the versioning that Java binary serialization uses.