Do Hibernate table classes need to be Serializable?
Is there any actual need for these classes to implement Serializable?
The JPA spec (JSR 220) summarizes it pretty well (the same applies to Hibernate):
2.1 Requirements on the Entity Class
(...)
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, strictly speaking, this is not a requirement unless you need detached entities to be sent over the wire to another tier, to be migrated to another cluster node, to be stored in the HTTP session, etc.
If so, is there any tool to add a generated serialVersionUID field to a large number of classes at once
I think that you could batch this with the Serial version (Ant) Tasks.
Should we implement Serializable interface while making Domain Class in hibernate
If your entities are going to be transfered over a network, to be stored in an HTTP session, or even to be stored in a file on your hard disk then they must implement Serializable
. Otherwise Hibernate has nothing to do with Serialization, check more here
Do Hibernate table classes need to be Serializable?
Beans serialization in JSP
When and why JPA entities should implement the Serializable interface?
This usually happens if you mix HQL and native SQL queries. In HQL, Hibernate maps the types you pass in to whatever the DB understands. When you run native SQL, then you must do the mapping yourself. If you don't, then the default mapping is to serialize the parameter and send it to the database (in the hope that it does understand it).
Related Topics
Replace the Last Part of a String
Returning Overlapping Regular Expressions
Run Main Class of Maven Project
Adding Up Bigdecimals Using Streams
Choosing the Best Concurrency List in Java
Bigdecimal Equals() Versus Compareto()
Why Can't a Generic Type Parameter Have a Lower Bound in Java
Run .Exe File in Java from File Location
How to Pass List from Java to Oracle Procedure
Choose Between Executorservice's Submit and Executorservice's Execute
Drawing in Jlayeredpane Over Exising JPAnels
How to Print Line Numbers to the Log in Java
How to Find Out the Currently Logged-In User in Spring Boot
Why Doesn't Java Allow Generic Subclasses of Throwable