There are another questions that seems to ask the same, but it is not still clear for me some aspects when I have to work with one aggregate root (AR) that need information from another AG.
One similiar question is this, DDD: aggregate root needs information from another aggregate root, but it is still not clear some things.
My doubt is this. Supose that I have Order and Buyer. I guess both are AG (if some guess is incorrect, correct me). Suponse that the order needs information of the buyer, for example if the buyer is allows to make orders or not.
One of the rules in DDD is that an AG can't have a reference to the object to another AG, only the ID, so my Order AG would be like this:
Order
{
long Id,
BuyerId,
....
}
In the question that I linked above, it is said: "If the domain logic for Screening requires gender and birth date, then you are going to need to get copies of those values into the aggregate".
It tells it is needed to have the values into the aggregate. Does this mean that in this case, could I have a reference to the object of the buyer instead of the ID?
Or perhaps I could have another option, to use a factory to create an order, that receive the ID of the buyer, then the factory request the information to the BuyerRepository, do the check and if the buyer can make orders, then assign the ID to the order.
This in the creation. But another case is for example when I need to show the information in the UI to the user. do I need to do two queries for that? One to get the information of the order aggregate and another query to get the information of the related aggregate entities, and compiste the information in the UI?
Thanks.