繁体   English   中英

Intellij IDEA @OneToMany mappingBy属性错误解决

[英]Intellij IDEA @OneToMany mappedBy attribute error resolving

我在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;
}

我的问题

不应将mapledBy属性值作为表名。 在双向关联中,应该是映射该关联的另一个实体中的属性名称。

例:

public class Country {
    // ...

    @OneToMany(mappedBy = "parentCountry");
    private Set<City> cities;
}

public class City {
    // ...

    @ManyToOne
    @JoinColomn(name = "country_id")
    private Country parentCountry;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM