1

我想用 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

有任何想法吗?谢谢。

4

1 回答 1

0

问题出在休眠版本中。在 4.1.7 中,这是错误的。我将版本更改为 4.1.4,一切正常

于 2013-07-08T10:36:03.997 回答