I'm not understanding how to do something that is probably very easy to do. I have a table named "Composer". A "Composer" can have many compositions ("Composition" table). I get the following error when I run this through Spring Boot:
19:11:40 web.1 | Caused by: org.hibernate.AnnotationException:
mappedBy reference an unknown target entity property:
com.zack.music.domain.Composition.composition in com.zack.music.domain.Composer.compositions
Below are my entity classes. What am I doing wrong here?
package com.zack.music.domain;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
import java.util.*;
@Entity
public class Composer implements Serializable {
@Id
private String name;
private Date birth;
private Date death;
@OneToMany(mappedBy="composition")
private List<Composition> compositions;
protected Composer() { }
public Composer(String name, Date birth, Date death) {
this.name = name;
this.birth = birth;
this.death = death;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public Date getDeath() {
return death;
}
public void setDeath(Date death) {
this.death = death;
}
public List<Composition> getCompositions() {
return compositions;
}
public void setCompositions(List<Composition> compositions) {
this.compositions = compositions;
}
}
@Entity
public class Composition implements Serializable {
@Id
@Column(nullable = false)
private String name;
@ManyToOne
private Composer composer;
protected Composition() { }
public Composition(String name, Composer composer) {
this.name = name;
this.composer = composer;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Composer getComposer() {
return composer;
}
public void setComposer(Composer composer) {
this.composer = composer;
}
}