JPA Self Join using JoinTable

后端 未结 3 2045
攒了一身酷
攒了一身酷 2020-12-12 03:33

I have 1 entity call Item in which I want to be able to link parent items to children. to use a join table to create a parent/child relationship. I haven\'t been able to g

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 03:50

    I believe @JoinTable is only allowed on a @OneToOne or @OneToMany or @ManyToMany, I don't think it makes any sense on a @ManyToOne. Use a @JoinColumn, or a @OneToOne.

    Also your @OneToMany does not make sense, the mappedBy must be an attribute and you have no parentItem, it should be parent, and parent should use a @JoinColumn.

提交回复
热议问题