重复定义 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;
}
return art_posterID;
}