ReferencedColumnNames未使用复合键映射到单个属性

时间:2016-11-18 14:30:57

标签: java dictionary jpa

那么, 在阅读了几乎所有帖子后,我决定发布我的问题,因为我无法修复它。

  • A类有一个主键(4个字段)
  • B类有一个主键(2个字段)

    @Entity
    public class ClassA implements Serializable {
        private static final long serialVersionUID = 1L;
    
        @EmbeddedId
        private ClassAPK id;
    
        //bi-directional many-to-one association to ClassB
        @OneToMany(mappedBy="classA")
        private Set<ClassB> classB;
    

B类

@Entity
public class ClassB implements Serializable {
    private static final long serialVersionUID = 1L;


    @AttributeOverrides({
            @AttributeOverride(name = "id", column = @Column(name = "ID")),
            @AttributeOverride(name = "cod", column = @Column(name = "cod")),
            @AttributeOverride(name = "year", column = @Column(name = "year")),
            @AttributeOverride(name = "month", column = @Column(name = "month")) })
    @EmbeddedId
    private ClassBPK id;

    // bi-directional many-to-one association to ClassA
    @ManyToOne
    @JoinColumns({
            @JoinColumn(name = "id", referencedColumnName="ID")
             })
    private ClassA classA;


@Embeddable
public class ClassBPK implements Serializable {
    //default serial version id, required for serializable classes.
    private static final long serialVersionUID = 1L;

    @Column(name="ID")
    private long id;

    private int day;

    public ClassBPK() {
    }

enter image description here

有什么建议吗? 感谢

0 个答案:

没有答案