JPA列数错误

时间:2016-10-18 12:35:00

标签: jpa join hibernate-mapping composite-primary-key

使用Spring Framework JPA我有Entity

@Entity
@IdClass(ComposityKey.class)
@Table(name="table1")
public class Table1 {
    @Id
    @Column(name="tableId)
    private int tableId;

    @Id
    private int tableId2;
    ...
}

第二个Entity包含对Table1

的引用
@Entity
@Table(name = "table2")
public class Table2 {

    @ManyToOne
    @JoinColumn(name="tableId")
    private Table1 table1;
}

现在我得到了明显的AnnotationException

A Foreign key refering Table1 from Table2 has the wrong number of column. should be 2

Table2没有tableId2作为值

那么我如何在复合键JoinColumn

0 个答案:

没有答案