SSH+注解+配置多对一关系报错

coleven 2016-05-08 11:29:04
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;
}
...全文
111 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧