首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Hibernate对象照射关系。多态

2012-08-02 
Hibernate对象映射关系。多态?3种策略?hibernate中解决映射对象存在多态关系是一般使用3种策略。???共享同一

Hibernate对象映射关系。多态

?

3种策略?

hibernate中解决映射对象存在多态关系是一般使用3种策略。??

?共享同一个表

在该策略下,父类和子类数据都在一个表中。假设有3个类Container、Box、Bottle。其中Container<-Box,Container<-Bottle。对于这种策略,一般是使用discriminator。

?

?

?

<hibernate-mapping>    <class name="Container">        <id name="containerId">            <generator type="string"/>        <property name="size"/>        <property name="name"/>        <subclass name="Box" discriminator-value="BOX">            <property name="height"/>            <property name="length"/>            <property name="width"/>        </subclass>        <subclass name="Bottle" discriminator-value="BOTTLE">             <property name="diameter"/>             <property name="height"/>         </subclass>    </class></hibernate-mapping>

?

?

?

 

热点排行