JavaOmnibus
J2EE Composite Entity
J2EE pattern • Integration
J2EEIntegrationJava example

Composite Entity solves a specific structural problem in the design.

Represent a coarse-grained entity composed of dependent persistent parts.

Pattern overview

J2EE pattern

Represent a coarse-grained entity composed of dependent persistent parts.

Intent

Model a coarse-grained entity that owns and coordinates a set of dependent objects.

Problem

A higher-level business entity spans several dependent persistent objects that should be managed together.

Solution

Expose one composite root that coordinates updates and lifecycle for its dependent parts.

Fit and tradeoffs

FamilyJ2EE
CategoryIntegration
Best used when
  • For aggregate-style persistence where dependent objects should move together.
Tradeoffs
  • Coarse-grained updates can become heavy if the boundary is too large.

Java example

This example is intentionally compact so the pattern shape stays easy to see.

public final class CustomerAccount {
    private Profile profile;
    private BillingDetails billingDetails;
    private Preferences preferences;

    public void updateBilling(BillingDetails billingDetails) {
        this.billingDetails = billingDetails;
    }
}

Related pages

Keep exploring