G
Gast2
Gast
Hallo,
ich versuche in Hibernate gereade eine manytomany beziehung
hier meine 2 klassen
Was ist daran falsch??
Ich bekomme folgende Exception
ich versuche in Hibernate gereade eine manytomany beziehung
hier meine 2 klassen
Code:
@Entity@Table(name = "EVENT")
public class Event {
private List<Person> person;
@ManyToMany(mappedBy = "event",
targetEntity=Event.class)
public List<Person> getPerson() {
return person;
}
public void setPerson(List<Person> person) {
this.person = person;
}
Code:
@Entity@Table(name="PERSON")
public class Person {
@ManyToMany( targetEntity=event.Event.class,
cascade={CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(
name="PERSON_EVENT",
joinColumns = @JoinColumn( name="person_id"),
inverseJoinColumns = @JoinColumn( name="event_id"))
@OrderBy("title desc")
public List<Event> getEvents() {
return events;
}
Was ist daran falsch??
Ich bekomme folgende Exception
Code:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: event.Event.event in event.Event.person
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:578)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1319)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
at test.TestMain.main(TestMain.java:22)
Initial SessionFactory creation failed.org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: event.Event.event in event.Event.person
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:18)
at test.TestMain.main(TestMain.java:22)
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: event.Event.event in event.Event.person
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:578)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1319)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 1 more