このコンテンツは選択した言語では利用できません。
6.2.2. Collection Foreign Keys
Collection instances are distinguished in the database by the foreign key of the entity that owns the collection. This foreign key is referred to as the collection key column, or columns, of the collection table. The collection key column is mapped by the
<key>
element.
There can be a nullability constraint on the foreign key column. For most collections, this is implied. For unidirectional one-to-many associations, the foreign key column is nullable by default, so you may need to specify
not-null="true"
.
<key column="productSerialNumber" not-null="true"/>
<key column="productSerialNumber" not-null="true"/>
The foreign key constraint can use
ON DELETE CASCADE
.
<key column="productSerialNumber" on-delete="cascade"/>
<key column="productSerialNumber" on-delete="cascade"/>
See the previous chapter for a full definition of the
<key>
element.