I would like to place the method in CategoryRepository if you want some Category:
public interface CategoryRepository {
List<Category> findWithMaterialsOfCategoriesSubtreesBeloningTo(ProductId productId);
}
And as far as I know, Knowing the structure of product is the only feasible and effcient way of implementing this.
Please allow me to quote Eric Evan's dddsample:
public interface HandlingEventRepository {
/**
* @param trackingId cargo tracking id
* @return The handling history of this cargo
*/
HandlingHistory lookupHandlingHistoryOfCargo(TrackingId trackingId);
}
What if the requirment changed to returning all HandlingEvent of an unshipped cargo? Then I have to join t_cargo and t_handling_event and filtering by "where t_cargo.status = ?".