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

前端 未结 5 1679
伪装坚强ぢ
伪装坚强ぢ 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:06

    You are not allowed to use a concrete implementation on the entities field declaration. You are allowed to use one of the following:

    • java.util.List
    • java.util.Set
    • java.util.Collection

    So in your case it would have to be:

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

提交回复
热议问题