我在 Invoice 和 InvoiceDetail 之间创建了如下所示的映射。尝试更新发票时,我也注意到用户的更新语句。当我们设置了 cascade =“none” 时,为什么要更新“用户”?
<class name="Invoice" table="invoice" lazy="false">
<id name="InvoiceID" column="InvoiceID" type="int">
<generator class="native"/>
</id>
<property name="InvoiceDate" column="InvoiceDate" type="DateTime"></property>
<property name="InvoiceNo" column="InvoiceNo" type="String"></property>
<property name="TotalAmount" column="TotalAmount" type="Decimal"></property>
<many-to-one class=User" name="User" column="UserID" cascade ="none" />
<component name="InvoiceDetailList">
<bag name="items" table="invoicedetail" lazy="false" cascade="all-delete-orphan" access="field" inverse="true" >
<key column="InvoiceID" on-delete="cascade" />
<one-to-many class="InvoiceDetail"/>
</bag>
</component>
</class>
<class name="InvoiceDetail" table="invoicedetail" lazy="false">
<id name="InvoiceDetailID" column="InvoiceDetailID" type="int">
<generator class="native"/>
</id>
<property name="ProductID" column="EntityID" type="int"></property>
<property name="Quantity" column="Quantity" type="int"></property>
<property name="TotalPrice" column="TotalPrice" type="Decimal"></property>
<many-to-one class="Invoice" name="Invoice" column="InvoiceID" not-null="true"/>
</class>
谢谢
阿努拉格