How to retrieve Aggregate objects?

Posted by Jebb on Stack Overflow See other posts from Stack Overflow or by Jebb
Published on 2010-06-03T09:23:17Z Indexed on 2010/06/03 9:24 UTC
Read the original article Hit count: 281

Filed under:
|
|
|

In DDD, Repository takes care of saving and retrieving domain objects and also serves as collection of Aggregate Roots. My question is how do you retrieve the information for those child entities (let's say from DB) of an Aggregate where basic rule is Repository should just hold collection of Aggregate Roots (parent object) and not child objects?

For example:

User (parent object) Orders (child object)

User domain object is stored in user table and Orders are stored in another table.

Basically, retrieving a Domain Object could be like this:

<?php
$userRepos = new UserRepository();
$user = $userRepos->find($userId);
?>

How then the child object (Orders) of User entity be retrieve to be as part of the User aggregate?

© Stack Overflow or respective owner

Related posts about php

Related posts about repository