“Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements”

前端 未结 5 1603
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 16:27

Good morning Stackoverflow,

I have the problem that it gives me the error:

Failed to create sessionFactory object.org.hibernate.AnnotationExcept

5条回答
  •  迷失自我
    2021-01-31 17:01

    You should map to interfaces and not implementations. This:

    @OneToMany(cascade=CascadeType.ALL, targetEntity=CoachGroup.class)
    @JoinColumn(name="id")
    private TreeSet coachGroups = new TreeSet<>();
    

    Should be (also replaced the TreeSet because a HashSet is enough here):

    @OneToMany(cascade=CascadeType.ALL, targetEntity=CoachGroup.class)
    @JoinColumn(name="id")
    private Set coachGroups = new HashSet<>();
    

提交回复
热议问题