hibernate MappingException (insert="false" update="false")

来源:互联网 发布:win10桌面软件图标 编辑:程序博客网 时间:2024/06/17 17:32

重复定义 model 的某个属性,就会导致出现MappingException (insert="false" update="false")

比如下面的需求,art_posterID 既要当独立属性,又要被作为 User 的映射字段:

private User user;

private int art_posterID;

@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="art_posterID",referencedColumnName ="user_id", insertable = false, updatable = false)
public User getUser() {
        return user;
}

public int getArt_posterID() {
        return art_posterID;

}

原创粉丝点击