# One-to-one mapping

Use a One-to-One Mapping to define a relationship with one-to-many multiplicity.

1. In the Persistence Outline view, select the field to map. The Persistence Properties view (for attributes) displays the properties for the selected.

2. In the Map As field, select One-to-one.

3. Use this table to complete the remaining fields on the General tab in Persistence Properties view.

   Property | Description | Default
   --- | --- | ---
   Target Entity | The entity to which this attribute is mapped. | null You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.

   Cascade Type

   See "Cascade Type" for details.

   - Default

   - All

   - Persist

   - Merge

   - Remove

   Default

   Fetch Type

   Defines how data is loaded from the database. See "Fetch Type" for details.

   - Eager

   - Lazy

   Eager

   Optional | Specifies if this field is can be null. | Yes
   Mapped By | The database field that owns the relationship. |

4. Use this table to complete the fields on the Join Columns tab tab in the Persistence Properties view.

   Property | Description | Default
   --- | --- | ---
   Join Column | Specify a mapped column for joining an entity association. This field corresponds to the `@JoinColum` attribute. Select Override Default, then Add, Edit, or Remove the join columns. | By default, the mapping is assumed to have a single join.

Eclipse adds the following annotations to the field:

    @OneToOne(targetEntity=<TARGET_ENTITY>, cascade=CascadeType.<CASCADE_TYPE>,
        fetch = FetchType.<FETCH_TYPE>, mappedBy = "<MAPPED_BY>")
    @JoinColumn(name="<JOIN_COLUMN_NAME>", referencedColumnName=
        "<JOIN_COLUMN_REFERENCED_COLUMN>", insertable = <INSERTABLE>,
        updatable = <UPDATABLE>)

Mapping an entity

Persistence Outline view
Persistence Properties view (for attributes)

Understanding OR mappings
Understanding JSR220: EJB 3.0