[英]Can one aggregate root reference a non aggregate root of another aggregate root?
I have three entities for this particular scenario: 对于这种特定情况,我有三个实体:
Since QuestionFeedback is inside a Question, can QuestionFeedbackCategory hold a list of QuestionFeedback objects too? 由于QuestionFeedback位于Question中,因此QuestionFeedbackCategory是否也可以保存QuestionFeedback对象的列表? Or does QuestionFeedbackCategory need to deal only with Question objects?
还是QuestionFeedbackCategory只需要处理Question对象?
If both Question and QuestionFeedback have Categories and assuming each can only have one category, I would model it this way 如果Question和QuestionFeedback都具有类别,并且假设每个类别只能具有一个类别,则可以这样建模
public class Question {
...
CategoryId categoryId;
Set<QuestionFeedback> feedback;
...
}
public class QuestionFeedback {
...
CategoryId categoryId;
...
}
public class Category {
CategoryId id;
String name;
String description;
}
You don't have to put the AR itself "inside" another AR/VO. 您不必将AR本身放在另一个AR / VO内部。 You can just reference its Value Object that acts as the id.
您可以仅引用其作为id的Value Object。
Edit: Read the three part article mentioned here http://dddcommunity.org/library/vernon_2011 . 编辑:阅读此处提到的三部分文章, 网址为http://dddcommunity.org/library/vernon_2011 。 Coming from an ORM mindset, I used to get confused on how to model these types of relationships.
来自ORM的心态,我以前对如何为这些类型的关系建模感到困惑。
The aggregate root can communicate with the outside only in these scenarios: 聚合根只能在以下情况下与外部通信:
but in all above options, no reference is allowed only array(the hydrated object) can be used. 但在以上所有选项中,不允许引用 ,只能使用数组(水合对象)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.