# One-to-many mapping

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

1. In the JPA Structure view, select the field to map.

2. Right-click the field and then select Map As > One-to-many. The JPA Details view (for attributes) displays the properties for the selected.

   JPA Details, One-to-many Mapping

3. Complete each field in the One-to-Many Mapping area.

4. Complete the remaining areas in the JPA Details view (for attributes):

   - Joining Strategy

   - Converters

   - Ordering

Eclipse adds the following annotations to the field:

    @OneToMany(targetEntity=<TARGET_ENTITY>)
    @Column(name="<COLUMN>")

    @OneToMany(targetEntity=<TARGET_ENTITY>.class,
        =Type.<_TYPE>,
        fetch = FetchType.<FETCH_TYPE>,
        mappedBy = "<MAPPED_BY>"
    )@OrderBy("<ORDER_BY>")
    @JoinTable(name="<JOIN_TABLE_NAME>", joinColumns=@JoinColumn(name=
        "<JOIN_COLUMN_NAME>", referencedColumnName="<JOIN_COLUMN_REFERENCED_COLUMN>"),
        inverseJoinColumns=@JoinColumn(name="<INVERSE_JOIN_COLUMN_NAME>",
        referencedColumnName="<INVERSE_JOIN_COLUMN_REFERENCED_COLUMN>"))

Related tasks

- Mapping an entity

Related references

- JPA Structure view

- JPA Details view (for attributes)

- Joining Strategy

- Converters

- Ordering

Related concepts

- Understanding OR mappings

- Understanding Java Persistence API