title: spring data neo4j relationship in entity
body: <p>Image I have the following entity: Company and Employee, with spring data neo4j annotation:</p>
  
  <p><strong>Company.java</strong></p>
  
  <pre><code>@NodeEntity(label = "Company")
  public class Company {
      /**
       * Graph ID
       */
      @GraphId
      private Long id;
      ......
  }
  </code></pre>
  
  <p><strong>Employee.java</strong></p>
  
  <pre><code>@NodeEntity(label = "Employee")
  public class Employee {
      /**
       * Graph ID
       */
      @GraphId
      private Long id;
      ......
  }
  </code></pre>
  
  <p>Then there is the relationship entity for these entities:</p>
  
  <pre><code>@RelationshipEntity(type = "EMPLOY")
  public class EmployRel {
      /**
       * Graph ID
       */
      @GraphId
      private Long id;
      @StartNode
      private Company company;
      @EndNode
      private Employee employee;
      ......
  }
  </code></pre>
  
  <p>So how to keep the reference in <code>Company</code> and <code>Person</code>?</p>
  
  <p><strong>Company.java</strong></p>
  
  <pre><code>@Relationship(type = "EMPLOY", direction = Relationship.OUTGOING)
  private Set&lt;EmployRel&gt; employeeRel = new HashSet&lt;&gt;();
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>@Relationship(type = "EMPLOY", direction = Relationship.OUTGOING)
  private Set&lt;Employee&gt; employee = new HashSet&lt;&gt;();
  </code></pre>
  
  <p><strong>Person.java</strong></p>
  
  <pre><code>@Relationship(type = "EMPLOY", direction = Relationship.INCOMING)
  private Company company = new Company();
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>@Relationship(type = "EMPLOY", direction = Relationship.OUTGOING)
  private EmployRel employRel = new EmployRel();
  </code></pre>