2013-07-08 80 views
0

我想使用InheritanceType.JOINED在數據庫中存儲超類和子類。但每次我嘗試這樣做,我得到一個錯誤 - Repeated column in mapping for entity: com.inqool.personalpro.entity.QuestionAlgorithm column: id (should be mapped with insert="false" update="false") 這裏有我的實​​體:java hibernate - 具有InheritanceType.JOINED的重複列

@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; 
    } 
    ... 
} 

當我從子類中刪除字段「身份證」,我得到這個錯誤:Could not locate table which owns column [id] referenced in order-by mapping

什麼想法?謝謝。

回答

0

問題在於hibernate的版本。在4.1.7中,這是錯誤的。我將版本更改爲4.1.4,並且一切正常。

相關問題