Reputation: 13195
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
Upvotes: 0
Views: 143
Reputation: 52735
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)
Upvotes: 2