现在,我正在学习hibernate,并开始在我的项目中使用它.这是一个CRUD应用程序.我使用hibernate进行所有的crud操作.它适用于所有人.但是,One-To-Many和Many-To-One,我厌倦了尝试它.最后它给了我以下错误.
org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)]
然后我再次浏览了这个视频教程.一开始对我来说非常简单.但是,我不能让它发挥作用.现在,它说
org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)]
我在互联网上运行了一些搜索,有人告诉它在Hibernate中有一个错误,有些人说,通过添加@GenereatedValue,这个错误将被清除.但是,nothings对我有用,
我希望我能得到一些解决方案!
谢谢!
在这里我的代码:
College.java
@Entity
public class College {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int collegeId;
private String collegeName;
private List<Student> students;
@OneToMany(targetEntity=Student.class, mappedBy="college", fetch=FetchType.EAGER)
public List<Student> getStudents() {
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}//Other gettters & setters omitted …Run Code Online (Sandbox Code Playgroud)