0

我有两个表“组”和“客户”,当然还有两个实体“组”和“客户”。我有另一个表,它同时引用了“CustomerGroupMember”表。

我使用 CustomerGroupMember 表进行多对多映射。

客户.hbm.xml

<!--Many to many-->
    <bag name="CustomerGroups" table="CustomerGroupMember" cascade="all" lazy="true">
      <key column="CustomerId" />
      <many-to-many class="CustomerGroup" column="CustomerGroupId" />
    </bag> 

组.hbm.xml

<bag name="Members" table="CustomerGroupMember" cascade="all" lazy="true">
      <key column="CustomerGroupId" />
      <many-to-many class="Customer" column="CustomerId" />
</bag>

我还没有为“CustomerGroupMember”表创建实体和映射。

我的问题是如何从 CustomerGroupMember 表中删除 CustomerGroupMember?我需要为 CustomerGroupMember 创建一个实体才能删除 CustomerGroupMember 还是有其他方法?

非常感谢你。

4

1 回答 1

1

要删除这些表之间的关系项,您应该能够以某种方式引用联结表中的确切行,这在当前映射中是不可能的。是的,您必须为CustomerGroupMember表创建实体和映射。如果没有映射,你怎么知道要删除哪一行?

于 2009-01-11T13:54:13.320 回答