2013-07-08 44 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,并且一切正常。

相关问题