[英]Can we have models who depends on each other?
class Parent {
long id;
List<Child> children;
}
class Child {
long id;
Parent parent;
}
GET /parents/1, here have to show children of Parent 1 GET /parents/1,这里必须显示 Parent 1 的孩子
GET /children/101 here have to show Parent of Child 101 GET /children/101 这里必须显示孩子 101 的父母
I actually didnt like above circular dependency design, but I am not understanding how to fix above scenario.我实际上不喜欢上述循环依赖设计,但我不明白如何解决上述情况。 Need some help to fix above design issue.
需要一些帮助来解决上述设计问题。
And also iam not sure whether can we have DTOs who depends on each other?而且我不确定我们是否可以拥有相互依赖的 DTO? Is this correct design?
这是正确的设计吗?
Yes.是的。 You can have models that depend on each other.
您可以拥有相互依赖的模型。 This is widely used in hibernate.
这在 hibernate 中被广泛使用。 Your example is like one to many mapping.
您的示例就像一对多映射。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.