我希望使用InheritanceType.JOINED将超类和子类存储在数据库中。但每当我尝试这样做时,我都会收到错误 - Repeated column in mapping for entity: com.inqool.personalpro.entity.QuestionAlgorithm column: id (should be mapped with insert="false" update="false")
这是我的实体:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Question implements Serializable {
private Long id;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
...
}
@Entity
@PrimaryKeyJoinColumn(name="id")
public class QuestionAlgorithm extends Question {
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
...
}
当我从子类中删除字段'id'时,我收到此错误:Could not locate table which owns column [id] referenced in order-by mapping
任何想法?感谢。
答案 0 :(得分:0)
问题出在hibernate的版本中。在4.1.7中,这是错误的。我将版本更改为4.1.4,一切正常