本文介绍了XML MAP NHIBERNATE问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用nhibernate将数据插入到我的表中.我的表格是Campaign和CampaignVendor

Campaign表包含以下列:

ID
名称
VendorId

而CampaignVendor具有

ID -Pk
CampaignId -FK
VendorId -FK

我尝试使用下面的此文件映射xml

I can''t insert data into my table with nhibernate. My tables are Campaign and CampaignVendor

The Campaign table has columns:

Id
Name
VendorId

And CampaignVendor has

Id -Pk
CampaignId -FK
VendorId -FK

I try to map xml with this file below

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
                   assembly="Hcl.Mam.Core"
                   namespace="Hcl.Mam.Core"&gt;
  <class name="Campaign" table="dbo.Campaign">
    <id name="Id" column="Id" unsaved-value="0">
      <generator class="hilo" />
    </id>
        <property name="Name" column="Name" />
        <many-to-one name="Vendor" column="VendorId" class="Vendor" />
      <bag name="AditionalVendors" table="CampaignVendor" cascade="save-update" lazy="false">
      <key column="VendorId" />
      <many-to-many class="Campaign" column="CampaignId" />
    </bag>
   </class>
</hibernate-mapping>




但是,它不起作用或显示错误消息.

表CampaignVendor中的ID列不允许使用空值.
可能会生成pk到CampaignVendor ...

我该如何解决?




However, it doesn''t work or show me an error message.

The column Id in table CampaignVendor does not allow null values.
inst possible generate the pk into CampaignVendor...

How can i solve this?

推荐答案


这篇关于XML MAP NHIBERNATE问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 22:33