Joined: Thu Sep 13, 2007 4:50 pm Posts: 1 Location: Columbus, OH
|
|
How do you delete a record with NHibernate with a composite key where one column is nullable?
I have the NHibernate mapping file set up correctly for my Marketing List object but I can't delete a record because of the null value in the composite key (I didn't set up the database and the database column can't be changed because of other systems). I get the standard Unexpected row count: 0; expected: 1
Can I do a CreateSQL or CreateHQL to do the delete?
Below is the SQL that NHibernate is spitting out:
DELETE FROM MARKETING_LIST WHERE FK_MJ_MJ_NUMBER = :p0 AND FK_MV_MV_NUMBER = :p1 AND LIST_SYSID = :p2 AND INS_COVERAGE_SUBTYPE = :p3; :p0 = '53494', :p1 = '101', :p2 = '10101', :p3 = ''
Below is the important pieces of the NHibernate Mapping. InsuranceCoverageSubtype is a nullable character column.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Affinion.M1.Business"
assembly="Affinion.M1.Business"
default-access="field.camelcase-underscore">
<!-- NHibernate mapping for Marketing List (Corresponds to table CUC_CONTROL.MARKETING_LIST) -->
<class name="MarketingList" table="MARKETING_LIST" mutable="true" lazy="true">
<!--Primary Key-->
<composite-id>
<key-property name="MarketingJobNumber" column="FK_MJ_MJ_NUMBER" />
<key-property name="MarketingVersionNumber" column="FK_MV_MV_NUMBER" />
<key-property name="ListId" column="LIST_SYSID" />
<key-property name="InsuranceCoverageSubtype" column="INS_COVERAGE_SUBTYPE" />
</composite-id>
<!--Properties-->
<property name="Quantity" column="QUANTITY" />
<property name="DeleteFlag" column="DELETE_FLAG" />
_________________ Thanks,
Greg Finzer
|
|