16 January 2012

The names of the primary key fields must correspond

I've faced some JPA Error (deployment-time error) which is:

The names of the primary key fields or properties in the primary key class [class FooBarPK] and those of the entity bean class [class FooBar] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.

The error appears when deploying some JPA project in Oracle App Server.

I've this entity:


@Entity
@IdClass(FooBarPK.class)
public class FooBar implements Serializable {
    
    private static final long serialVersionUID = 1L;
    

    @Id
    private Long id1;
    @Id
    private Long id2;
    
    //...
}

//And this is the PK class 

public class NewParaPK implements Serializable 
{
    private static final long serialVersionUID = 1L;

    private Long id1;
    private Long id2;
}

I wonder, why this happen...

I found this line:
private static final long serialVersionUID = 1L;

In the PK Class who cases the problem!

Post a Comment