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.
The steps to embed a class within another class involves:
- Designating the class that can be embedded with the @Embeddable annotation
- Embedding the embeddable class into the other class using the @Embedded annotation
We will expand upon the previous recipe and augment the