'how to return relationship in spring data neo4j

Here's nodeEntity

@Data
@NodeEntity
public class Resource {
    @Id
    @GeneratedValue
    private Long id;
    @Property("name")
    private String name;
    private String code;
    @Property("parent_code")
    private String parentCode;
    private String label;

    private Neo4jRelationship relationship;
}

And here's relationship between nodes

@Data
@RelationshipEntity
public class Neo4jRelationship {
    @Id
    private Long id;
    @StartNode
    private Resource startNode;

    @EndNode
    private Resource endNode;
}

I want to query all the relationship satify some condition,

@Query("match p = (a : category_first {name: $name})-[*1..2]-() return p")
    List<Neo4jRelationship> getFistCatNode(@Param("name") String name);

but the query return am empty list.

However, if I change the return type to org.neo4j.ogm.model.Result, the query can return normally. enter image description here

I'm confused why the first way dosen't work. Any help will be grateful



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source