我有点问题 JPA中的@OneToMany(mappedBy =" table_name")注释。 所以我们有2个表(截图的所有细节) 我添加了一个数据源,但我仍然有错误"无法解析属性"
我能以某种方式解决它吗?
@Id
@Column(name = "state_id")
public int getStateId() {
return stateId;
}
public void setStateId(int stateId) {
this.stateId = stateId;
}
@Basic
@Column(name = "description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Basic
@Column(name = "systemname")
public String getSystemName() {
return systemName;
}
public void setSystemName(String systemname) {
this.systemName = systemname;
}
@OneToMany(mappedBy = "note_states")
public Set<Note> getNotes() {
return notes;
}
public void setNotes(Set<Note> notes) {
this.notes = notes;
}
答案 0 :(得分:2)
mappedBy属性值不应该是表名。在双向关联中,它应该是另一个实体中属性的名称,用于映射关联。
示例:
public class Country {
// ...
@OneToMany(mappedBy = "parentCountry");
private Set<City> cities;
}
public class City {
// ...
@ManyToOne
@JoinColomn(name = "country_id")
private Country parentCountry;
}