Northwind数据库中的Customers表,配置如下:<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernateTest" 
                   namespace="NHibernateTest.NHibernateSimple.Domain.Entities">
  <class name="Customer" table="Customers" >
    <id name="Customerid" column="[CustomerID]" type="string">
      <!--<generator class="native" />-->
      <!--<generator class="assigned" />-->
    </id>
    <property type="string" length="30" name="ContactTitle" column="[ContactTitle]" />
    <property type="string" length="60" name="Address" column="[Address]" />
    <property type="string" length="15" name="City" column="[City]" />
    <property type="string" length="15" name="Region" column="[Region]" />
    <property type="string" length="10" name="PostalCode" column="[PostalCode]" />
    <property type="string" length="15" name="Country" column="[Country]" />
    <property type="string" length="24" name="Phone" column="[Phone]" />
    <property type="string" length="24" name="Fax" column="[Fax]" />    <bag name="CustomerDemographics" lazy="true" table="[CustomerCustomerDemo]" cascade="all" inverse="false">
      <key column="[CustomerID]" />
      <many-to-many class="CustomerDemographic">
        <column name="[CustomerTypeID]"  />
      </many-to-many>
    </bag>
    <bag name="Orders" inverse="true" lazy="true" cascade="all">
      <key column="[CustomerID]" />
      <one-to-many class="Order" />
    </bag>
  </class>
</hibernate-mapping>直接用主键得到实体,然后修改实体的ID,再保存会报错。我估计得再加一个用于标识的东西才行。但是怎么加?或者还有没有别的方法。
错误代码:
Customer customer = customerDao.GetCustomerById("WOLZA");
customer.Customerid = "HOW";
customer.ContactName = "DONT";
customerDao.UpdateCustomer(customer);