I'm getting a Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: model.Rol.Acteur in model.Acteur.rollen exception.
Now I don't really see anything wrong with these classes (both are in the package model):
Code:
@Entity
@Table(name = "T_ACTEUR")
public class Acteur {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Acteur")
@SequenceGenerator(name = "Acteur", sequenceName = "SEQ_ACTEUR", allocationSize = 1)
private int id;
private String voornaam;
private String familienaam;
@OneToMany(mappedBy = "Acteur")
private Set<Rol> rollen = new HashSet<Rol>();
public Acteur(String voornaam, String familienaam, Set<Rol> rollen) {
this.voornaam = voornaam;
this.familienaam = familienaam;
this.rollen = rollen;
}
//getters
//setters
/add Rol function
}
Code:
@Entity
@Table(name = "T_ROL")
public class Rol {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Rol")
@SequenceGenerator(name = "Rol", sequenceName = "SEQ_ROL", allocationSize = 1)
private int id;
private String naam;
@ManyToOne
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@JoinColumn(name = "acteurId")
private Acteur acteur;
@ManyToOne
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@JoinColumn(name = "filmId")
private Film film;
public Rol(String naam, Acteur acteur, Film film) {
this.naam = naam;
this.acteur = acteur;
this.film = film;
}
//getters
//setters
}
They're both declared in my hibernate.cfg.xml, and I don't really see anything wrong with them.
Any input is welcome.
The error list:
Code:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: model.Rol.Acteur in model.Acteur.rollen
Exception in thread "main" java.lang.ExceptionInInitializerError
at persistence.HibernateUtil.<clinit>(HibernateUtil.java:23)
at model.test.main(test.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: model.Rol.Acteur in model.Acteur.rollen
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:543)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:508)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1136)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at persistence.HibernateUtil.<clinit>(HibernateUtil.java:18)
... 6 more
If it's helpful in any way.