SSH+注解+配置多对一关系报错
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed;
nested exception is org.hibernate.MappingException: Could not determine type for: com.hams.entity.Dept, at table: hams_doctorss, for columns: [org.hibernate.mapping.Column(dept)]
@Entity
/*数据库表名名称*/
@Table(name="hams_doctorss")
public class Doctor {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int doctor_id;
@Column
private String doctor_name;
//多对一的关系
private Dept dept;
/*多对一关系设置*/
@ManyToOne()
@JoinColumn(name="dept_id")//指定外键名称
public Dept getDept() {
return dept;
}
public void setDept(Dept dept) {
this.dept = dept;
}