org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: com.bjsxt.model.Student.courses

在做Student与Course多对多的关联,出现上述异常

1.请检查Student的courses这个属性是否使用了泛型,:Set<Course>. 

如果未使用泛型,请在@ManyToMany注释中使用targetEntity指定元素的类型 即@ManyToMany(targetEntity=Course.class)

2.注意当你使用了泛型即Set<Course>时,也要确保你对应的geters, seters方法也是使用泛型,要不然也会报上述错误




 

posted @ 2013-04-06 11:44  springstudent  阅读(816)  评论(0编辑  收藏  举报