Element collection mapping

Use an Element Collection to define a collection of Basic objects. The Basic values are stored in a separate collection table. Because the target is a Basic value (instead of an Entity), you can easily define collections of simple values without having to define a class for the value.

To create an element collection mapping:

  1. In the JPA Structure view, right-click the field to map. Select Map As > Element Collection. The JPA Details view (for attributes) displays the properties for the selected field.

    JPA Details, Element collection mapping

    JPA Details, Element collection mapping
  2. Complete each field in the Element Collection Mapping area.

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

Eclipse adds the following annotations to the field:

@ElementCollection
@CollectionTable(
        name="<TABLE_NAME>",
        joinColumns=@JoinColumn(name="<COLUMN_TABLE>")
)
@Column(name="<COLUMN_TABLE>")

Related tasks

Related references

Related concepts