I have a little problem with @OneToMany(mappedBy = "table_name") annotations in JPA. So we have 2 tables (all details on screenshot) I added a datasource, but i still have error "Cannot resolve attribute"
Can i resolve it some way?
@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;
}

The mappedBy attribute value is not supposed to be a table name. It's supposed to be, in a bidirectional association, the name of the attribute in the other entity, that maps the association.
Example:
public class Country {
// ...
@OneToMany(mappedBy = "parentCountry");
private Set<City> cities;
}
public class City {
// ...
@ManyToOne
@JoinColomn(name = "country_id")
private Country parentCountry;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With