我浏览了许多视频和教程,解释了如何使用注释机制在休眠中配置一对多关系。我仍然收到此错误。
错误是:org.hibernate.AnnotationException:使用@OneToMany 或@ManyToMany 瞄准未映射的类:bean.Professor.coursesAssigned[bean.Course] 使用@OneToMany 或@ManyToMany 瞄准未映射的类:bean.Professor.coursesAssigned[豆.课程]
我的课程是:
教授.java
package bean;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
@Entity
public class Professor extends User{
@OneToMany(targetEntity = Course.class, mappedBy = "assignedProfessor",
cascade = CascadeType.ALL , fetch = FetchType.LAZY)
private Set<Course> coursesAssigned;
}
course.java 是:
package bean;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
public class Course {
private Integer courseId;
private String courseName;
@ManyToOne(targetEntity = Professor.class)
@JoinColumn(name = "professor_join")
private Professor assignedProfessor;
}