子类之间many-to-many关联出现问题

super class 为 Subject,两个子类User和UserGroup

做多对多关联无法在关联表建立外键约束
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="uac.model.businessobjects">
 <class name="Subject" table="tbSubject_info" abstract="true">
  <id name="sequenceId" type="integer" column="PK_Sequence">
   <generator class="native">
    <param name="sequence">SUBJECT_SEQUENCE</param>
   </generator>
  </id>
  <discriminator column="VC_SubjectType" type="string"
   length="1">
  </discriminator>
  <!--维护主体与角色的多对多关联 -->
  
  <property name="subjectId" type="string" column="LK_SubjectID"
   length="10" unique="true">
  </property>
  <subclass name="User" discriminator-value="U" extends="Subject">

   <!--维护用户与用户组的多对多关联 -->
   <set name="groups" inverse="true" table="tbUser_Org_Rel">
    <key column="FK_UserID" property-ref="userId" ></key>
    <many-to-many class="UserGroup" column="FK_OrgID"
     property-ref="orgId" />
   </set>


   <join table="tbUser_info" >
    
    <key column="PK_USER" foreign-key="User_Subject_FK">
    </key>

    <property name="userId" column="VC_UserID" type="string"
     length="10" not-null="true" unique="true">
    </property>
       </join>

  </subclass>
  <subclass name="UserGroup" discriminator-value="G" extends="Subject">

   <!--维护用户组与用户的多对多关联 -->
   <set name="users" inverse="true" table="tbUser_Org_Rel">
    <key column="FK_OrgID" property-ref="orgId"></key>
    <many-to-many class="User" column="FK_UserID" property-ref="userId" />
   </set>

   <join table="tbUserGroup_info">
    <key column="PK_UserGroup"
     foreign-key="UserGroup_Subject_FK">
    </key>
    <property name="orgId" column="VC_OrgID" type="string"
     length="10" not-null="true" unique="true">
    </property>
   
   </join>

  </subclass>

 </class>

</hibernate-mapping>

你可能感兴趣的:(.net,xml,Hibernate,vc++)