[英]Having aggregate root as property?
Can aggregate roots have childs which also is aggregate roots? 聚合根是否可以具有子节点,而子节点又是聚合根? If yes, does it only reference it or does the aggregate root that holds a property of the other aggregate root have methods that changes it through that method?
如果是,它是仅引用它还是拥有其他聚合根属性的聚合根具有通过该方法更改它的方法?
Let say you have a class named "Worker" and another named "Company". 假设您有一个名为“ Worker”的类,另一个为“ Company”。 Both are aggregate roots.
两者都是聚合根。 Company have a property of Worker.
公司拥有工人财产。 Sorry for making a bad example
很抱歉做出不好的榜样
public class Company {
private Worker worker;
...
public Worker getWorker() {
...
}
}
public class Worker {
...
}
or does the company class "hide" the worker? 还是公司类别“隐藏”工人?
public class Company {
private Worker worker;
...
public String getWorkerName() {
...
}
}
public class Worker {
...
}
And does worker talk only to the company class because it is not part of the company context? 工人是否只与公司阶层对话,因为这不是公司背景的一部分? Why so?
为什么这样? Are aggregate roots contained inside other aggregate roots always accessed like my first example?
是否像我的第一个示例一样总是访问包含在其他聚合根中的聚合根? (I would think so, but I have no reason why)
(我会这样认为,但是我没有理由)
In short, no. 简而言之,没有。
This is kinda tough to explain succinctly in a SO answer, but here's a few bullet points that may help your understanding: 在SO答案中很难简洁地解释这一点,但是这里有一些要点可以帮助您理解:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.