开发者

check if NHibernate entity is contained in multiple entities

I would like to ensure that开发者_运维问答 an entity is contained in at most one single entity. Is it possible to check this from the mapping files? In SQL land, I want to ensure that if a table has a foreign key, that there are no repeated entries in the foreign key column.

Thanks!

Jorge


Just make the FK unique:

<many-to-one unique="true" />

Or, from the collection side:

<key>
  <column unique="true"/>
</key>

(I omitted all attributes non related to the problem)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜