Difference between Serializable and non Serializable object save into database Difference between Serializable and non Serializable object save into database database database

Difference between Serializable and non Serializable object save into database


In general, no difference at all. having an entity as Serializable for persistence is not a must, and strictly depends on the framework which you are using for your persistence layer.

e.g. Hibernate does not require at all, though it is a best practice to make entities Serializable, as per JPA specification -

If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.

So if you need detached entity for example in HTTP session, or to pass to another layer, Serialize them, etc - you need to have your entities as Serializableobjects.