/ hsQpH.png
图中显示了3个表格。 OPERATION_KEY和OPERATIONACTION_KEY是各自表中的标识列和pk。
我希望在OperationResult表中将OPERATIONACTION_KEY和OPERATION_KEY作为nhibernate映射中的Foreignkeys。
当OperationResult存在于Operation时,OPERATIONACTION_KEY应该在OperationResult表中保存为零
当OperationAction的OperationResult存在时,OPERATION_KEY应该在OperationResult表中保存为零。
如何在OperationResult.hbm.xml中映射它?
以下是我尝试的映射文件,但是我收到错误。
<set name="OperationResults" inverse="true" cascade="save-update" >
<key column="OPERATIONACTION_KEY" />
<one-to-many class="OperationResult" />
</set>
<set name="OperationResultValueGroups" inverse="true" cascade="save-update" >
<key column="OPERATIONACTION_KEY" />
<one-to-many class="OperationResultValueGroup" />
</set>
<set name="OperationResults" inverse="true" cascade="save-update" >
<key column="OPERATIONACTION_KEY" />
<one-to-many class="OperationResult" />
</set>
<set name="OperationResultValueGroups" inverse="true" cascade="save-update" >
<key column="OPERATIONACTION_KEY" />
<one-to-many class="OperationResultValueGroup" />
</set>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
namespace="Volvo.SDE.HIST.Common.Entities"
assembly="Volvo.SDE.HIST.Common.Entities" >
<class name="OperationResult" table="HIST_OperationResult" lazy="true">
<composite-id>
<key-many-to-one name="OperationActionDetail" column="OPERATIONACTION_KEY" class="OperationAction" not-found="ignore" />
<key-many-to-one name="OperationDetail" column="OPERATION_KEY" class="Operation" not-found="ignore" />
<key-property name="RESULT_TYPE" column="RESULT_TYPE" type="string" length="50"/>
<key-property name="EVENT_SEQ" column="EVENT_SEQ" type="Int32" />
<key-property name="OPERATION_RESULT_SEQ" column="OPERATION_RESULT_SEQ" type="Int32" />
<key-property name="RESULT_STEP_SEQ" column="RESULT_STEP_SEQ" type="Int32" />
<key-property name="ITEM_SEQ" column="ITEM_SEQ" type="Int32" />
</composite-id>
<version name="ObjectVersion" column="ObjectVersion" type="Int32" unsaved-value="0"/>
<property name="ITEM" column="ITEM" type="string" length="100"/>
<property name="VALUE" column="VALUE" type="string" length="500"/>
</class>