Hibernate亲子建模
我有一个模型课。这个类应该能够引用自身,即模型产生的“输出”应该像这样。
Some instanceOf Model.class
|-> Some instanceOf Model.class having parent instance referenced as parent_id
|-> Some instanceOf Model.class having ...........
这些实例代表按层次结构组织的地理实体。老实说,我不知道如何实现这一点。
I have a Model class. This class should be able to reference itself, i.e. the resulting "output" from the model should be like this.
Some instanceOf Model.class
|-> Some instanceOf Model.class having parent instance referenced as parent_id
|-> Some instanceOf Model.class having ...........
The instances represent geographical entities organized in a hierarchy. To be honest I have no idea how to implement this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个开始的地方。根据需要使用父级和/或子级,具体取决于您想要如何导航层次结构。我将让您填写详细信息。
Here's a place to start. Use parent and/or children as needed depending on how you want to navigate the hierarchy. I'll leave it to you to fill in the details.
正如您的问题所示,您有@OneToOne 的
问候,
As shown in your question, you have a @OneToOne
regards,