Why is this JPA 2.0 mapping giving me an error in Eclipse/JBoss Tools?

后端 未结 3 701
盖世英雄少女心
盖世英雄少女心 2021-01-23 04:02

I have the following situation:
(source: kawoolutions.com)

JPA 2.0 mappings (It might probably suffice to consider only the Zip and ZipId class

3条回答
  •  忘掉有多难
    2021-01-23 04:08

    I have not tested your code, but it looks pretty much related to the use of the @PrimareKeyJoinColumn annotation.

    The JPA 2.0 specification in section 11.1.40 states:

    The PrimaryKeyJoinColumn annotation is used to join the primary table of an entity subclass in the JOINED mapping strategy to the primary table of its superclass; it is used within a SecondaryTable annotation to join a secondary table to a primary table; and it may be used in a OneToOne mapping in which the primary key of the referencing entity is used as a foreign key to the referenced entity[108].

    The example in the spec looks like your case.

    @Entity
    @Table(name="CUST")
    @Inheritance(strategy=JOINED)
    @DiscriminatorValue("CUST")
    public class Customer { ... }
    
    @Entity
    @Table(name="VCUST")
    @DiscriminatorValue("VCUST")
    @PrimaryKeyJoinColumn(name="CUST_ID")
    public class ValuedCustomer extends Customer { ... }
    

    I hope that helps!

提交回复
热议问题