JPA reference table mapping

若如初见. 提交于 2019-12-06 08:14:33

If what you really have is a OneToMany (which means that a give tableB.id appears at most once in TableC), then the mapping is the following:

@OneToMany
@JoinTable(name = "TableC",
           joinColumns = @JoinColumn(name = "TABLE_A_ID"),
           inverseJoinColumns = @JoinColumn(name = "TABLE_B_ID"))
private List<TableBEntity> tableBItems;

Else, what you have is in fact a ManyToMany, and the mapping is the same, except that @OneToMany must be replaced by @ManyToMany.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!