kamal
kamal

Reputation: 759

Root aggregate reference problem

Can an entity inside aggregate which is not root can hold reference to root aggregate. Or is root aggregate can only hold reference to its child entities.

Upvotes: 1

Views: 521

Answers (1)

Sisyphus
Sisyphus

Reputation: 4231

An entity within an aggregate can hold a reference to the aggregate root.

Entities within an aggregate may also hold references to other, external aggregate roots.

External objects may NOT hold a reference to an entity that is internal to the aggregate. External objects must reference the aggregate root only, no internal objects.

Only aggregates should be returned from queries/repositories.

An aggregate should be created as an entire set, typically using a factory.

Upvotes: 6

Related Questions