Reading through Serialization chapter from Effective Java, I realized I still have some Serializable
s here and there in my codebase (Spring Boot web app -> Spring Data -> Hibernate). The recommendation is to avoid serialization as much as one can.
Do I still need to implement Serializable
?
What are the reasons for doing so in Hibernate?
If I do so, how can it be exploited?
example:
@MappedSuperclass
@Getter
public class AbstractEntityWithVersion<ID extends Serializable> implements Identifiable<ID> {
@Id
private final ID id;
@Version
@Column(name = "REC_VERSION", nullable = false)
private Long version;
protected AbstractEntityWithVersion() {
this.id = null;
}
}
public interface Identifiable<ID extends Serializable> {
ID getId();
}
Why does ID in this example have to be Serializable
?