This pattern is used in EJB (Enterprise Java Beans) persistence mechanism. A composite entity represents the object graph and is an EJB entity. Whenever a composite entity is updated, the object beans that are internally dependent on this bean are updated automatically. There are 4 main components of the Composite Entity Pattern:
- Composite Entity - Primary entity bean that can have a coarse-grained object that is meant for persistence.
- Coarse-Grained Object - This contains the dependent objects which have their life cycle and in turn manages the lifecycle of dependent objects.
- Dependent Object - This object is dependent on the coarse-grained object throughout the persistence lifecycle.
- Strategies - These represent how to implement the composite entity.