看一下你的@OneToMany(mappedBy = “XXXXX”)是不是没有加mappedBy,不加默认会生成第三张表管理关系。
(mappedBy = “project”)对应另一类中映射属性值
mappedBy属性在@OneToOne、@OneToMany 、@ManyToMany关系中可以添加,@ManyToOne不支持,举个例子:
public class Project implements Serializable{
@Column(name = "project_id")
private Long id;
@Column(name = "project_name")
private String name;
@OneToMany(mappedBy = "project")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Principals> principals = new HashSet<>();
/*getter setter toString...*/
}
public class Principals implements Serializable{
@Column(name = "principals_id")
private Long id;
@Column(name = "principals_name")
private String name;
@ManyToOne
@JsonIgnoreProperties("principals")
private Project project;
/*getter setter toString...*/
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/115842.html