These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Deleting Records with a composite key where one col is null
PostPosted: Thu Sep 13, 2007 5:04 pm 
Newbie

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.