I used to read a coding best practice is the entity of hibernate should not implement
java.io.Serializable
.
My idea is just for better performance, to avoid compiler processing something for the entity. And we should use DTO serialized to communicate client and server instead.
Is it right?
Thank so much!
That's not a best practice at all, and implementing serializable or not doesn't have any impact on performance. If you want to be able to serialize your entities, make them implement Serializable. If you don't want to, then don't make them implement Serializable. It's as simple as that.
Using a DTO when the entity itself contains the adequate information is rather viewed as an anti-pattern than viewed as a best practice.