gpt4 book ai didi

java - 组织.hibernate.MappingException : Could not determine type for:

转载 作者:行者123 更新时间:2023-11-30 10:28:40 24 4
gpt4 key购买 nike

org.hibernate.MappingException: Could not determine type for: com.qoobico.remindme.server.entity.Group, at table: student, for columns: [org.hibernate.mapping.Column(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;
}
}

最佳答案

Student 中属性 group 的映射应该是:

@ManyToOne
@JoinColumn(name = "group_id")
private Group group;

您不能在字段和属性级别混合注释。将这些注释移至该字段,一切都会如您所愿。

关于java - 组织.hibernate.MappingException : Could not determine type for:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44475949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com