See Online manual for further details:
There are two varieties of one-to-one association:
* primary key associations
* unique foreign key associations
Primary key associations don't need an extra table column; if two rows are related by the association then the two table rows share the same primary key value. So if you want two objects to be related by a primary key association, you must make sure that they are assigned the same identifier value!
For a primary key association, add the following mappings to Employee and Person, respectively.
<one-to-one name="person" class="Person"/>
<one-to-one name="employee" class="Employee" constrained="true"/>
Alternatively, a foreign key with a unique constraint, from Employee to Person, may be expressed as:
<many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/>
And this association may be made bidirectional by adding the following to the Person mapping:
<one-to-one name"employee" class="Employee" property-ref="person"/>
|