开发者

NHibernate - Deleting objects with composite PK, when one of the PK columns is NULL

Hey, i'm trying to delete an entity of the following structure from an Oracle 10g tables:

class Record 
{
   string id;
   string name;
   DateTime dateTime;
}

with the following mapping:

<class name="Records" table="RECS">
   <composite-id>
      <key-property name="P_ID" />
      <key开发者_JS百科-property name="NAME" />
   </id>
   <property name="dateTime" column="DATE_TIME_V" />
</class>

Now, say that the table's PK is P_ID and NAME columns (composite key), when NAME allow nulls but P_ID doesn't. Now, the issue is that when NHibernate tries to delete an object with, say, P_ID = 9 and NAME = NULL, it outputs the following delete statement:

delete from RECS R where R.P_ID = 9 and NAME = NULL

Obvioisly, the operation will delete nothing since 'NAME = NULL' should be 'NAME IS NULL'. Am i'm missing something here that causes NHibernate to treat nulls like any other values?

Thanks, Harel


"say that the table's PK is P_ID and NAME columns (composite key), when NAME allow nulls"

Not possible. A primary key column cannot be null. What you have is a table WITHOUT a primary key, which is why you are getting problems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜