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

转自:http://blog.sina.com.cn/s/blog_8f4353ce01011j15.html

hibernate出现Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements:com.model.user.course
的原因可能是user实体类中course这个列表不是List类型的,可能是它的子类型比如说ArrayList,如果要把一个ArrayList列表OneToMany应该这样

List course = new ArrayList<>();

你可能感兴趣的:(Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements)