I have an Entity class with composite PK as below:
using @Embeddable and @EmbeddedId annotations.
/** The primary key class for the uom_conversion database table. */
@Embeddable
public class UomConversionPK implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="product_id", insertable=false, updatable=false)
private int productId;
@Column(name="base_uom_id", insertable=false, updatable=false)
private int baseUomId;
@Column(name="to_unit_id", insertable=false, updatable=false)
private int toUnitId;
//getters, setters
}
And the Entity which is using it is:
/** The persistent class for the uom_conversion database table. */
@Entity
@Table(name="uom_conversion")
public class UomConversion implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private UomConversionPK id;
}
Here Eclipse is displaying error: "UomConversionPK cannot be resolved to a type"
In another project I'm using Entities with composite PK without any errors.
Now this seems to be a JPA facet problem, wondering why Eclipse is not able to resolve UomConversionPK or am I doing something wrong ?
Well this error do occur sometimes for @EmbeddedId
annotation, though not always, when creating JPA entities from tables using JPA Tools.
In my case this problem was not resolved until I set the following to Ignore
and then back to Error
:
Windows -> Preferences -> Java Persistence -> JPA -> Errors/Warnings -> Embedded ID classes should implement hashcode() and equals()
. This error occurs even if Embeddable class do have hashcode() and equals() method implementation. May be this works for you as well.