Using embeddable classes in entities

A common relationship between classes is composition. One class may declare and use another class as a field to support some common functionality. For example, the PartsBean may have a need to maintain the location of the part using some sort of bin location scheme. This scheme may also be used for classes other than a part. This need is addressed for entities using the @Embeddable and @Embedded annotations.

Getting ready

The steps to embed a class within another class involves:

  1. Designating the class that can be embedded with the @Embeddable annotation
  2. Embedding the embeddable class into the other class using the @Embedded annotation

    We will expand upon the previous recipe and augment the EntityBeanApplication ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.