One-to-one relationship

Consider a one-to-one relationship where one employee belongs to a single department. You can use code like the following to define a one-to-one mapping between the Department and Employee objects with DEPTID as the foreign key column name.
[Entity] 
[Table(name="employee")] 
public class Employee 
    { 
        [Id] 
        var id:uint; 
        [OneToOne(targetEntity="Department"|fetchType="EAGER(default)|LAZY")] 
        [JoinColumn(name="DEPTID", referencedColumnName="DEPT_ID")] 
        var dept:Department; 
    }

The [JoinColumn]tag specifies the foreign key column and all the attributes of the column tag. Do not specify [JoinColumn] for both the entities in the relationship. For example, in the one-to-one relationship between the Department and Employee objects, specify [JoinColumn]only for one of the entities depending on the direction of the relationship.

referencedColumnName specifies the primary key column that it refers to. Class indicates the target entity, which is Department in this example.

The default fetchType value is EAGER. See Lazy loading and fetch type for information on fetch types.