开发者

NHibernate - composite-id - 3

开发者 https://www.devze.com 2022-12-18 12:30 出处:网络
I have a class in Nhibernate hbm file and for this I\'m using a composite id field, in the following way :

I have a class in Nhibernate hbm file and for this I'm using a composite id field, in the following way :

 <composite-id>
    <key-many-to-one name="DContent" class="Business.Entities.DContent, Business" column="DId" />
    <key-many-to-one name="Structure" class="Business.Entities.Structure, Business" column="RId"/>
    <key-property name="Language"></key-property>
 </composite-id>

</class>

where DContent & Structure are cla开发者_如何学JAVAsses and Language is an int.

I've overwritten the Equals & GetHashCode methods, to keep trace of the 3 objects in the composite key, but what I've discovered is that when it's creating the table in the database only the two DId & RId are part of the primary key, and not the Language.

My question is : Why NHibernate doesn't see that the Language is part of the primary key??

Thank you, Catalin

0

精彩评论

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