자식 행을 삽입 할 때 NHibernate가 부모 개체를 삽입하려고하는 이유 (행이 이미 db에있을 때)를 이해하지 못합니다.Nhibernate - 자식을 삽입 할 때 기존 부모 행을 삽입하려고하는 이유
부모 매핑 :
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="ReportDistribution.Client.ReportMgr.Model.ClientReport, ReportDistribution.Client.ReportMgr.Model"
table="ClientReport"
lazy="false"
dynamic-update="true">
<id name="Id" access="property" column="ReportID">
<generator class="assigned"></generator>
</id>
<property name="MaxAge" access="property" />
<property name="DeleteUnread" access="property" />
<property name="Description" access="property" />
<property name="Name" access="property" />
<bag name="ClientPublications" cascade="all" lazy="false">
<key column="ReportID" />
<one-to-many class="ReportDistribution.Client.ReportMgr.Model.ClientPublication, ReportDistribution.Client.ReportMgr.Model" />
</bag>
</class>
</hibernate-mapping>
아이 매핑 :
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="ReportDistribution.Client.ReportMgr.Model.ClientPublication, ReportDistribution.Client.ReportMgr.Model"
table="ClientPublication"
lazy="false"
dynamic-update="true">
<id name="Id" access="property" column="PublicationID">
<generator class="assigned"></generator>
</id>
<property name="CreatedOn" access="property" type="DateTime"></property>
<property name="IsMarkedForDeletion" access="property"></property>
<property name="IsDeleted" access="property"></property>
<property name="HasBeenRead" access="property"></property>
<property name="ReceivedOn" access="property" type="DateTime"></property>
<property name="FileExtension" access="property"></property>
<property name="IsDownloaded" access="property"></property>
<property name="MustRead" access="property"></property>
<many-to-one
name="Report"
class="ReportDistribution.Client.ReportMgr.Model.ClientReport, ReportDistribution.Client.ReportMgr.Model"
lazy="false"
column="ReportID">
</many-to-one>
</class>
</hibernate-mapping>
부모 클래스 (보고서) 자식 클래스의 모음입니다 속성이 있습니다. Child 클래스 (발행물)에는 부모 개체 인 속성이 있습니다. 당신이 아이를 저장할 때 부모 개체가 더 이상 세션에 연결되어있는 것처럼 사전에
덕분에 ....
ClientPublications 가방에 inverse = true를 넣으려고 했습니까? – Rashack
게시 키 열에 NULL을 삽입했기 때문에 ADOException이 발생합니다. – empo
유감스럽게도 마지막 발언은 id generator를 "native"로 변경했기 때문에 무시되었습니다. – empo