Hi,
I'm using a SQL DB and when trying to create a driver with address information I get an error that tells me this:
Quote:
Cannot insert explicit value for identity column in table 'DRIVERADDRESSES' when IDENTITY_INSERT is set to OFF.
DRIVERADDRESSES is an intermediate class.
The mapping looks like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"
namespace="Address" assembly="Domain">
<class name="DriverAddresses" table="DriverAddresses">
<id name="DriverAddressID" column="DRIVERADDRESSESID" type="Int32">
<generator class="id_generator_Int32"/>
</id>
<property name="PersonID" column="PERSONID" type="Int32" not-null="true"/>
<property name="TnrId" column="TNRID" type="Int32" not-null="true"/>
<property name="ValidFrom" column="VALIDFROM" type="DateTime" not-null="true"/>
<property name="ValidTo" column="VALIDTO" type="DateTime" not-null="false"/>
<many-to-one name="Address" class="Address" column="ADDRESSID"
not-found="ignore" not-null="false" unique="true" cascade="save-update"
lazy="false" outer-join="true"/>
</class>
</hibernate-mapping>
The SQL being generated for the SQL statement is the following:
Code:
INSERT INTO DRIVERADDRESSES (PERSONID, TNRID, VALIDFROM, VALIDTO, ADDRESSID, DRIVERADDRESSESID) VALUES (@p0, @p1, @p2, @p3, @p4, @p5)
I have no idea however, why the DRIVERADDRESSESID is also being given as parameter in the insert statement. According to me this is not necessary at all.
Does anyone have an idea on how to solve this?