【发布时间】:2011-10-10 09:25:28
【问题描述】:
我正在扩展一个不会自动生成其 ID 的实体。
我想在派生类中将其生成策略“覆盖”为 AUTO。
类似的东西。
@Entity
public class Base {
@Id
@Column(name = "id")
public Integer getId() {
return id;
}
}
@Entity
public class Extender extends Base {
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
return super.getId();
}
}
这就是我尝试这样做时得到的结果:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: Extender column: id (should be mapped with insert="false" update="false")
我明白为什么会发生这种情况,但我需要知道是否有有效的方法来做到这一点。
谢谢,
【问题讨论】:
标签: java hibernate inheritance jpa