Reputation: 215
a create relation ManyToMany beetwen my Subject table and Group table. But I have problem with "mappedBy
Subject class :
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@Fetch(value = FetchMode.SUBSELECT)
@JoinTable(
name = "ugroup_subject",
joinColumns = @JoinColumn(
name = "subject_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(
name = "group_id", referencedColumnName = "id")
)
List<Group> groups;
Group class :
@ManyToMany(mappedBy = "group")
private List<Subject> subjects;
And this is my error :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.example.tim.model.Subject.group in com.example.tim.model.Group.subjects
Where did I make a mistake? Thank you in advance for your help !
Upvotes: 0
Views: 5331
Reputation: 15878
Typo here
Change @ManyToMany(mappedBy = "group")
to @ManyToMany(mappedBy = "groups")
Upvotes: 3