Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<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>



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?
Posted
Updated 2-Feb-11 0:24am
v4

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900