在Hibernate docs, § 5.1.6.2 - Joined subclass strategy中声明:
但是,每个子类必须声明一个包含对象标识符的表列。
它给出的例子如下:
@Entity @Table(name="CATS")
@Inheritance(strategy=InheritanceType.JOINED)
public class Cat implements Serializable {
@Id @GeneratedValue(generator="cat-uuid")
@GenericGenerator(name="cat-uuid", strategy="uuid")
String getId() { return id; }
...
}
@Entity @Table(name="DOMESTIC_CATS")
@PrimaryKeyJoinColumn(name="CAT")
public class DomesticCat extends Cat {
public String getName() { return name; }
}
我猜测name
不是对象标识符,因此DomesticCat
类中的“表列”包含“对象标识符“?通常我需要做什么才能将这个特定的必需列添加到我的子类型中?
答案 0 :(得分:0)
This is probably referring to the "id" field (not shown, but implied by the getId() method). This field is the unique identifier for the row in the "CATS" table containing the information you are looking for. It looks like it is setting the Type of id as String and is expecting a UUID. The sub-types will inherit this field due to their extension of the main class.