一旦你看到此組合鍵,並使用它們,我在代碼塊後下來的實體,請參考下pseudotable,我需要IdClass共享複合鍵在數據庫的地址實體:JPA - 錯誤試圖映射使用,而不是一個EmbeddedId
地址表:
ADDRESS
-------------------------------
DOCUMENTTYPE INT2 PK
DOCUMENTNR VARCHAR(10) PK
ALIAS VARCHAR(20) PK
FULLADDRESS VARCHAR(100)
...
實體&組合鍵:
@Embeddable
public class Document implements Serializable {
private DocumentType documentType;
private String documentNr;
...
@Entity
@IdClass(Document.class)
public class Person {
@Id
private DocumentType documentType;
@Id
private String documentNr;
private String fullName;
...
@Embeddable
public class AddressId implements Serializable {
private DocumentType documentType;
private String documentNr;
private String alias;
...
@Entity
@IdClass(AddressId.class)
public class Address {
@Id
@ManyToOne
private Person person;
@Id
private String alias;
private String fullAddress;
...
注意:DocumentType是枚舉。
那麼,我試圖讓地址實體的映射,但它不起作用,我不知道爲什麼。它一直說(EclipseLink),我有名稱和類型不匹配的問題。我不明白爲什麼如果IdClass沒有別名屬性(當然也沒有實體),那麼它就像一個魅力,以及與完整的AddressId IdClass(與別名屬性),但使用EmbeddedId。我需要的是像我發佈的地址實體。
映射錯誤在哪裏?
預先感謝您!
感謝您的迴應,但這不是因爲枚舉類型隱式地繼承ORDINAL賦值。 –