我有以下课程
@MappedSuperclass
public class Keyword {
private Integer code;
private Integer rating;
public Keyword() {}
public Integer getCode() {
return this.code;
}
public Integer getRating() {
return this.rating;
}
public void setCode(Integer code) {
this.code = code;
}
public void setRating(Integer rating) {
this.rating = rating;
}
}
我希望通过扩展此类来创建Entity
,我想将已存在的字段设置为主键(我不想创建新字段) ,所以我试着做这样的事情:
@Entity
@Table(name = "keyword")
//@AttributeOverride(name = "code", column = @Column(name = "code"))
public class MyKeyword extends Keyword {
@Override
@Id
@GeneratedValue
public Integer getCode() {
return super.getCode();
}
}
运行时出现以下错误
引起:org.hibernate.MappingException:映射中的重复列 for entity:com.foo.model.MyKeyword column:code(应该映射 with insert =" false"更新="假&#34)
知道如何正确配置它?请记住,我无法访问MappedSuperclass,我无法修改它。