我的JPA模型中有以下类(省略了getter,setter和不相关的字段):
@Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Currency {
    @Id
    private Integer ix;
}
@Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Product {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
}
我需要定义一个类Price,使得当从所述类生成DDL时,相应的表的主键被由密钥Product和Currency.我尝试过以下方法:
@Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@IdClass(PricePK.class)
public class Price {
    @Id @ManyToOne(optional = false)
    private Product product;
    @Id
    @ManyToOne(optional = false)
    private Currency currency;
}
@Embeddable
public class PricePK implements Serializable {
    Integer product;        
    Integer currency;
}
但是这会为PRICE表生成以下内容:
create table …