异常一:
org.hibernate.AnnotationException:Collection has neither generic type or OneToMany.targetEntity() defined: com.exam.Role
原因及解决方法:没有给对应的类Role的Set加泛型,hibernate不能判断关联的哪个对象。
private Set<Users> users=new HashSet(); //错误的!
private Set<Users> userses = new HashSet<Users>(); //正确的!
当然还有下面的set、get方法也要相应的加泛型!