0

Eclipse Heliosで正常にコンパイルされ、本番環境で正常に動作するJPAコードがあります。しかし、Eclipseの新しいバージョンでは、javax.persistence。*パッケージのアノテーション@IdClassを使用すると、「IDクラスをマップしないでください」というエラーが発生します。

@Entity
@IdClass(RetailLocationPK.class)  // Generates "ID class should not be mapped" error
@Table(name="loc_rtl_loc")
public class RetailLocation implements Serializable {
    @Id
    @Column(name="organization_id")    
    private int organizationId;

    @Id
    @Column(name="rtl_loc_id")
    private int rtlLocId;
...
}

次に、RetailLocationPK.javaに次のようになります。

@Embeddable
public class RetailLocationPK implements Serializable {
    //default serial version id, required for serializable classes.
    private static final long serialVersionUID = 1L;
    @Column(name="organization_id")
    private int organizationId;

    @Column(name="rtl_loc_id")
    private int rtlLocId;

    public RetailLocationPK() {
    }
    ...
}

最後に、persistence.xmlには、次のものがあります。

<persistence-unit name="taxPu" transaction-type="JTA">
    <class>tbss.persist.RetailLocation</class>
    <class>tbss.persist.RetailLocationPK</class>
    ...
</persistence-unit>

今のところエラー通知をオフにしていますが、なぜこれが発生するのですか?

4

1 に答える 1

0

あるべきではないかどうかはわかりませんが、@IdClass(とは異なり@EmbeddedId)間違いなくである必要はなく@Embeddable、でマッピングする必要はありません<class>

于 2012-06-26T20:58:47.423 に答える