One-to-Many Mapping


Use a One-to-Many 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-many.

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

    Property Description Default
    Target Entity The entity to which this attribute is mapped.
    Cascade Type See "Cascade Type" for details.
    • Default

    • All

    • Persist

    • Merge

    • Remove


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

    • Lazy


    Mapped By The database field that owns the relationship.
    Order By Specify the default order for objects returned from a query. See "Ordered By" for details.
    • Primary key

    Primary key

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

    Property Description Default
    Name Name of the join table By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.
    Join Columns

    Inverse Join Columns


Eclipse adds the following annotations to the field:

@Version
@Column(name="<COLUMN>")

 

Related task

Mapping an Entity

 

Related reference

Persistence Outline View
Persistence Properties View (for Attributes)

 

Related concept

Understanding OR Mapping
Understanding JSR220: EJB 3.0