JPA-hibernate注解之should be mapped with insert="false" update="false"

原文地址:https://blog.csdn.net/wwkms/article/details/48714123

报错信息: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;
}


猜你喜欢

转载自blog.csdn.net/tanga842428/article/details/80274901
今日推荐