About Question enthuware.oce-jpad.v6.2.572 :

Moderator: admin

Post Reply
unvector
Posts: 18
Joined: Sun Jun 21, 2015 2:56 am
Contact:

About Question enthuware.oce-jpad.v6.2.572 :

Post by unvector »

I am wondering whether primary key class does really need to be Serializable - spec. of JPA 2.0 says that:
The primary key class must be serializable.
(...)
The primary key class must define equals and hashCode methods.
But later in the same chapter we can see examples in section 2.4.1.3:

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 
}
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?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.572 :

Post by admin »

It could be an oversight on their part. Ideally, they should have specified "implements Serializable" in their code.

-Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests