How to modeling this relation in spring data neo4j?

允我心安 提交于 2020-01-05 06:32:28

问题


Given I have two entity: Person and Company, and there are multiple relationships between them:

Person - Company:

  1. The person can be the employee of the company
  2. The person can be the shareholder of the company
  3. The person can be the legal person of the company

Company - Company:

  1. The company can be the legal of the company
  2. The company can be the shareholder of the company

So how to modeling this in spring data neo4j?

What I tried is make 3 relationship types: EMPLOY, INVEST, LEGAL, each relationship type with the Company as the StartNode and the person as the EndNode, then in company and person, keep these relationships with the "UNDIRECTED" direction, just same as the diagram present, but always get the stackoverflow error when saving and searching.


回答1:


Yes, now here is the solution in github, all the classes are house in sample.spring.data.neo4j package, and the the corresponding test sample.spring.data.neo4j.repositories.CompanyRepositoryTest

The big issue at the beginning is it always throws the StackOverFlow exception which is due the the lombok annotation, after remove all the lombok annotations and use the plain getter/setter, everything goes well.



来源:https://stackoverflow.com/questions/46503104/how-to-modeling-this-relation-in-spring-data-neo4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!