©


Core J2EE Pattern Catalog

© CoreJ2EEPatterns
All Rights Reserved.

Last Updated:
January 29, 2006 8:54 PM

 

In Association with Amazon.com


Composite Entity

See Core J2EE Patterns, 2nd Edition for full description of this pattern and its strategies.

Problem

You want to use entity beans to implement your conceptual domain model.

Forces

  • You want to avoid the drawbacks of remote entity beans, such as network overhead and remote inter-entity bean relationships.
  • You want to leverage bean-managed persistence (BMP) using custom or legacy persistence implementations.
  • You want to implement parent-child relationships efficiently when implementing Business Objects as entity beans.
  • You want to encapsulate and aggregate existing POJO Business Objects with entity beans.
  • You want to leverage EJB container transaction management and security features.
  • You want to encapsulate the physical database design from the clients.

Solution

Use a Composite Entity to implement persistent Business Objects using local entity beans and POJOs. Composite Entity aggregates a set of related Business Objects into coarse-grained entity bean implementations.

Class Diagram

Sequence Diagram

Strategies

  • Composite Entity Remote Facade Strategy
  • Composite Entity BMP Strategies
  • Lazy Loading Strategy
  • Store Optimization (Dirty Marker) Strategy
  • Composite Transfer Object Strategy

Consequences

  • Increases maintainability
  • Improves network performance
  • Reduces database schema dependency
  • Increases object granularity
  • Facilitates composite transfer object creation

Related Patterns

  • Business Object
    The Business Object pattern describes in general how domain model entities are implemented in J2EE applications. Composite Entity is one of the strategies of the Business Object pattern for implementing the Business Objects using entity beans.
  • Transfer Object
    The Composite Entity creates a composite Transfer Object and returns it to the client. The Transfer Object is used to carry data from the Composite Entity and its dependent objects.
  • Session Façade
    Composite Entities are generally not directly exposed to the application clients. Session Façades are used to encapsulate the entity beans, add integration and web service endpoints, and provide a simpler coarse-grained interface to clients.
  • Transfer Object Assembler
    When it comes to obtaining a composite transfer object from the Business Object, the Composite Entity is similar to a Transfer Object Assembler. However, in this case, the data sources for all the Transfer Objects in the composite are parts of the Composite Entity itself, whereas for the Transfer Object Assembler, the data sources can be different entity beans, session beans, Data Access Objects, Application Services, and so on.
Contact Us © CoreJ2EEPatterns.com. All Rights Reserved. Terms of use