title: Spring Data Neo4j Repository for Relationship Entity
body: <p>I wish to query the RelationshipEntity like we query the NodeEntity.</p>
  <p>Package Info:</p>
  <pre><code>groupId=org.springframework.data
  artifactId=spring-data-neo4j
  version=5.1.5.RELEASE
  </code></pre>
  <p>I have posted the dummy code below. Please don't mind if there are any mistakes or errors as long as the concept is clear.</p>
  <hr />
  <hr />
  <p>NodeEntity (1) -&gt; Employee</p>
  <pre><code>@NodeEntity(&quot;Employee&quot;)
  public class Employee{
  
      @Id
      @GeneratedValue
      Long id;
      String name;
  
      // Id
      public Long getId() {
          return id;
      }
      public void setId(Long id) {
          this.id = id;
      }
      // Name
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
      @Relationship(type = STARTED, direction = Relationship.OUTGOING)
      private List&lt;Status&gt; starts = new ArrayList&lt;&gt;();
  
      @Relationship(type = PAUSED, direction = Relationship.OUTGOING)
      private List&lt;Status&gt; pause = new ArrayList&lt;&gt;();
  
      @Relationship(type = STOPED, direction = Relationship.OUTGOING)
      private List&lt;Status&gt; stops = new ArrayList&lt;&gt;();
  
      @Relationship(type = COMPLETED, direction = Relationship.OUTGOING)
      private List&lt;Status&gt; action = new ArrayList&lt;&gt;();
  
      // Default Relationship
      @Relationship(type = ACTION, direction = Relationship.OUTGOING)
      private List&lt;Status&gt; action = new ArrayList&lt;&gt;();
  }
  
  </code></pre>
  <hr />
  <p>NodeEntity (2) -&gt; Project</p>
  <pre><code>@NodeEntity(&quot;Project&quot;)
  public class Project{
  
      @Id
      @GeneratedValue
      Long id;
      String name;
  
      // Id
      public Long getId() {
          return id;
      }
      public void setId(Long id) {
          this.id = id;
      }
      // Name
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  }
  
  </code></pre>
  <hr />
  <p>RelationshipEntity -&gt; Status</p>
  <pre><code>@RelationshipEntity
  public class Status {
  
      @Id
      @GeneratedValue
      Long id;
      String name;
  
      // Id
      public Long getId() {
          return id;
      }
      public void setId(Long id) {
          this.id = id;
      }
      // Name
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
      @StartNode
      private Employee employee;
  
      @EndNode
      private Project project;
  }
  
  </code></pre>
  <hr />
  <p>This Repository works perfectly fine</p>
  <pre><code>public interface EmployeeRepository extends CrudRepository&lt;Employee, Long&gt; {
      Employee findByName(String name);
  
      @Query(&quot;MATCH (e:Employee)-[r]-&gt;(p:Project) WHERE e.name={empName} AND p.name={prjName} RETURN e &quot;)
      Employee getEmployeeWorkingOnProjectId(@Param(&quot;empName&quot;) String empName, @Param(&quot;prjName&quot;) String prjName);
  }
  </code></pre>
  <hr />
  <p>This Repository does not works.<br />
  <strong>getEmployeeWorkingOnProject(String,String)</strong> returns <strong>NULL</strong></p>
  <blockquote>
  <p>I have made modifications after <code>RETURN</code> keyword, for example modifying it from <code>RETURN *</code> to the alias like <code>RETURN e,r,p</code> and also tried changing the sequence of the alias in the return as well.</p>
  </blockquote>
  <blockquote>
  <p>I wish to get all the status (edges) associated with the specific employee and the specific project.</p>
  </blockquote>
  <pre><code>public interface StatusRepository extends CrudRepository&lt;Status, Long&gt; {
  
      @Query(&quot;MATCH (e:Employee)-[r]-&gt;(p:Project) WHERE e.name={empName} AND p.name={prjName} RETURN * &quot;)
      Status getEmployeeWorkingOnProject(@Param(&quot;empName&quot;) String empName, @Param(&quot;prjName&quot;) String prjName);
  
  
      /* OR 
      @Query(&quot;MATCH (e:Employee)-[r]-&gt;(p:Project) WHERE e.name={empName} AND p.name={prjName} AND r.name={statusName} RETURN * &quot;)
      Status getEmployeeWorkingOnProject(@Param(&quot;empName&quot;) String empName, @Param(&quot;prjName&quot;) String prjName, @Param(&quot;statusName&quot;) String statusName)
      */
  }
  </code></pre>
  <p><strong>CYPHER Result in Neo4j Browser</strong>:</p>
  <p>(Replaced the real project image with test image)</p>
  <h2><a href="https://i.stack.imgur.com/kL8RV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kL8RV.png" alt="enter image description here" /></a></h2>
  <h3>Desired Outcomes (For example)</h3>
  <pre><code>{
    Status: {
      name: ..,
      Employee: {
        ...
      },
      Project: {
        ...
      }
    }
  },
  {
    Status: {
      name: ..,
      Employee: {
        ...
      },
      Project: {
        ...
      }
    }
  },
  ..
  </code></pre>
  <p>OR</p>
  <pre><code>STARTED : {
    Employee: {
      ...
    },
    Project: {
      ...
    }
  },
  STOPPED : {
    Employee: {
      ...
    },
    Project: {
      ...
    }
  },
  </code></pre>
  <p>OR other kind of similar results where the Relationship entity holds both the connecting nodes.</p>