1
org.hibernate.MappingException:無法確定類型: com.qoobico.remindme.server.entity.Group,在表:學生,爲 列:[org.hibernate.mapping.Column(group)]org.hibernate.MappingException:無法確定類型:
我讀過所有帖子abot這個例外,但我不能解決這個問題。似乎一切都達是allrighrt,但我仍然得到它:
Group.java
@Entity
@Table(name = "party")
public class Group {
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name="increment", strategy = "increment")
private int id_group;
@Column(name = "groupName", nullable = false)
private String groupName;
@Column(name = "tutorName", nullable = false)
private String tutorName;
@OneToMany(targetEntity = Student.class,
mappedBy = "group",
cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
private List<Student> student;
public Group(){
}
public int getId_group() {
return id_group;
}
public void setId_group(int id_group) {
this.id_group = id_group;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getTutorName() {
return tutorName;
}
public void setTutorName(String tutorName) {
this.tutorName = tutorName;
}
public List<Student> getStudent() {
return student;
}
public void setStudent(List<Student> student) {
this.student = student;
}
}
Student.java
@Entity
@Table(name ="student")
public class Student {
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name="increment", strategy = "increment")
private int id_student;
@Column(name = "studentName", nullable = false)
private String studentName;
@Column(name = "formOfAducation")
private String formOfAducation;
@Column(name = "group")
private Group group;
@Column(name = "studentCourse")
private String studentCourse;
@Column(name = "studentSpecializatio")
private String studentSpecializatio;
@Column(name = "studentBookName")
private String studentBookName;
@Column(name = "studentGender")
private String studentGender;
public Student(){
}
public int getId_student() {
return id_student;
}
public void setId_student(int id_student) {
this.id_student = id_student;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getFormOfAducation() {
return formOfAducation;
}
public void setFormOfAducation(String formOfAducation) {
this.formOfAducation = formOfAducation;
}
@ManyToOne
@JoinColumn(name ="id_group")
public Group getGroup() {
return group;
}
public void setGroup(Group group) {
this.group = group;
}
public String getStudentCourse() {
return studentCourse;
}
public void setStudentCourse(String studentCourse) {
this.studentCourse = studentCourse;
}
public String getStudentSpecializatio() {
return studentSpecializatio;
}
public void setStudentSpecializatio(String studentSpecializatio) {
this.studentSpecializatio = studentSpecializatio;
}
public String getStudentBookName() {
return studentBookName;
}
public void setStudentBookName(String studentBookName) {
this.studentBookName = studentBookName;
}
public String getStudentGender() {
return studentGender;
}
public void setStudentGender(String studentGender) {
this.studentGender = studentGender;
}
}
但是我有它,但這樣的: ' @ManyToOne @JoinColumn(名稱= 「id_group」) 公共組getGroup(){ 返回組; } ' –
沒錯,但你不能混合字段和屬性級別的註釋。文檔很清楚,您應該選擇一種策略來註釋您的類並在實體層次結構中保持一致,否則您的持久性提供程序將忽略/跳過某些註釋。 Hibernate根據您放置@ @ Id的位置來確定哪種策略。鑑於你把它放在了現場,所有的註解應該在現場級別,而不是在getter/setter上。 – Naros
謝謝,它的工作原理! –