About Question enthuware.oce-jpad.v6.2.572 :
Posted: Tue Mar 21, 2017 11:15 am
I am wondering whether primary key class does really need to be Serializable - spec. of JPA 2.0 says that:
There is no "implements Serializable" as well as no hashCode() nor equals() methods. Are these examples make some assumptions about what is obvious to implement? Or they are complete?
But later in the same chapter we can see examples in section 2.4.1.3:The primary key class must be serializable.
(...)
The primary key class must define equals and hashCode methods.
Code: Select all
public class DependentId {
String name; // matches name of @Id attribute
long emp; // matches name of @Id attribute and type of Employee PK
}
Code: Select all
@Embeddable
public class DependentId {
String name;
long empPK; // corresponds to PK type of Employee
}