One to One association is represent that another persistent class is declared using a one to one element.
<one-to-one name="propertyName" class="ClassName" cascade="cascade_style" constrained="true|false" fetch="join|select" property-ref="propertyNameFromAssociatedClass" access="field|property|ClassName" formula="any SQL expression" lazy="proxy|no-proxy|false" entity-name="EntityName" node="element-name|@attribute-name|element/@attribute|." embed-xml="true|false" foreign-key="foreign_key_name" />
In the one to one association we don't need to add extra table column. when if two rows are related by the association then two table rows share primary key value. Two object by a primary key association relate to ensure that they are assigned the same identifier value.
<one-to-one name="person" class="Person"/> <one-to-one name="employee" class="Employee" constrained="true"/>
Ensure that the primary keys of the related rows in the PERSON and EMPLOYEE tables are equal.
<class name="person" table="PERSON"> <id name="id" column="PERSON_ID"> <generator class="foreign"> <param name="property">employee</param> </generator> </id> ... <one-to-one name="employee" class="Employee" constrained="true"/> </class>
A newly saved instance of Person is assigned the same primary key value as the Employee instance referred with the employee property of that Person.
<many-to-one name="person" class="Person" column="PERSON_ID" unique="true"/>
<one-to-one name="employee" class="Employee" property-ref="person"/>
Others
Languages
Frameworks
Web / Design
Mobile Technology
Sql & Technology
R4R