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)
精彩评论