Embedding an Embeddable

Overview

An embeddable class can be pinned either to an entity, or to another embeddable.

You can embed a single instance of the embeddable class, or a collection of the embeddable class.

Embedding a Single Element

  1. In the Composition list of Palette, choose Embed Single Element.

  2. Click on the source entity or the embeddable of the Has-A relationship or press ESCAPE to cancel.

  3. Click on the target embeddable of the Has-A relationship or press ESCAPE to cancel.

    The Eclipse IDE creates and visualizes the Has-A relationship, as well as the relevant embedded attribute in the entity, in which the embeddable is set.

    The attribute will be mapped with the @Embedded annotation.

Embedding Collection of Elements

  1. In the Composition list of Palette, choose Embed Collection of Elements.

  2. Click on the source entity or the embeddable of the Has-A relationship or press ESCAPE to cancel.

  3. Click on the target embeddable of the Has-A relationship or press ESCAPE to cancel.

    The Eclipse IDE creates and visualizes the Has-A relationship, as well as the relevant embedded attribute in the entity, in which the embeddable is set.

    The attribute will be mapped with the @ElementCollection annotation.

Removing Has-A Relationships

To remove a particular Has-A relationship, select the relation on the JPA diagram and press DELETE , or choose Delete from the context menu.

Removing a relationship via the JPA diagram also removes it from the application data model and deletes the embedded attributes of the embedding entity.