我正在尝试将此代码转换为 JPA 注释,但我完全对子类和连接感到困惑。
xxx.hbm.xml
<class name="com.domain.square" table="square" discriminator-value="0">
<id name="id" column="id">
<generator class="native" />
</id>
<discriminator column="squareType" type="integer" />
<property name="name" />
<property name="image" />
<property name="type" column="squareType" type="integer" insert="false" update="false" />
<property name="keywords" />
<subclass name="com.domain.Widget" discriminator-value="1">
<property name="periodical" />
</subclass>
<subclass name="com.domain.WidgetContainer" discriminator-value="2" />
<subclass name="com.more.domain.EmbedSquare" discriminator-value="3">
<join table="square_embed">
<key column="squareId"/>
<property name="objUrl" />
<property name="title" />
</join>
</subclass>
<subclass name="com.domain.social.SocialWidget" discriminator-value="4" />
</class>
Square.java
@Entity
@Table(name= "square")
@DiscriminatorColumn(columnDefinition = "squareType", discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue("0")
public class Square implements Indexable, Serializable{
@Id
@Column(length = 11)
@GeneratedValue
private int id;
...
}
我怎样才能继续学习子类?