报错信息:Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: cn.edu.svtcc.datas.model.ChaStupay column: XH (should be mapped with insert="false" update="false")
错误原因:由于同一个元素注解了两次,所有报错
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "XH")
public StuBasicinfo getStuBasicinfo() {
return this.stuBasicinfo;
}
@Column(name = "XM", length = 100)
public String getXm() {
return this.xm;
}
解决方法:1.删除一个注解元素 2.将其中一个具有映射关系的元素设置为只读,insertable = false, updatable = false
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "XH",insertable = false, updatable = false)
public StuBasicinfo getStuBasicinfo() {
return this.stuBasicinfo;
}
@Column(name = "XM", length = 100)
public String getXm() {
return this.xm;
}