在Hibernate映射文件中discriminator-value的含义是什么?

时间:2015-01-20 10:55:39

标签: java hibernate orm hibernate-mapping discriminator

<class name="admin.model.OrganizationUnit" table="ORGANIZATION_UNIT" discriminator-value="admin.model.OrganizationUnit" dynamic-update="true">

    <id name="ObjectId" type="string" column="object_id">
        <generator class="assigned"/>
    </id>
    <discriminator column="discriminator"/>
    <property name="ObjectType" type="string">
        <column name="ObjectType" sql-type="varchar2(255)" not-null="true"/>
    </property>

    <subclass name="admin.model.DmSystem" discriminator-value="admin.model.DmSystem" dynamic-update="true">

        <set name="ChildOrgs" lazy="true" table="ORGANIZATION_UNIT" where="ou_type_code='CWORG'">
            <key column="system_org_id"/>
            <one-to-many class="Dm.bizcomponent.admin.model.OrganizationUnit"/>
        </set>

        <set name="SystemAdminAccessGroup" lazy="true" inverse="true" table="CWGROUP" where="group_type_code='SYSTEM_ADMINACCESS'">
            <key column="owner_id"/>
            <one-to-many class="admin.model.Group"/>
        </set>
    </subclass>
</class>
  

这是映射代码   在上面的代码中,有一个父类OrganizationUnit,带有两个子类

1 个答案:

答案 0 :(得分:2)

discriminator-value用于确定与基类数据库表中给定数据库行条目关联的实体子类类型的类类型。