早安#1,「非法嘗試映射非集合作爲一個@OneToMany,@ManyToMany或@CollectionOfElements」
我有它給我的錯誤問題:
Failed to create sessionFactory object.org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: nl.scalda.pasimo.model.employeemanagement.EducationTeam.coachGroups
你知道爲什麼?
@OneToMany(cascade=CascadeType.ALL, targetEntity=CoachGroup.class)
@JoinColumn(name="id")
private TreeSet<CoachGroup> coachGroups = new TreeSet<>();
private SessionFactory factory;
private void initialiseFactory() {
try {
factory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);
}
}
?:
因此您的實際映射不會
TreeSet
工作,你應該使用的Set<CoachGroup>
代替TreeSet<CoachGroup>
–