Search code examples
javaspring-bootneo4jgraph-databasesspring-data-neo4j

Spring Data Neo4j - (all) properties of RelationsshipEntity


@NodeEntity
class A {
    @Relationship(type = "INCLUDES", direction = Relationship.UNDIRECTED)
    List<B> bs;
}

@NodeEntity
class B {}

class C {
    int something;
}

@RelationshipEntity(type = "INCLUDES")
class R {
    String property1;
    int property2;
    C c;

    @StartNode
    A a;

    @EndNode
    B b;
}

The goal to retrieve the relationship entity between two particular nodes (some instances of Aand B) with ALL its properties.

I tried the following cypher query:

MATCH (a:A)-[i:INCLUDES]-(b:B) RETURN i;

However, this only gives me an empty result. If I retrieve all INCLUDErelationship entities with the default Neo4jRepository.findAll() implementation, I can see that all properties are set.

Thanks for any help!


Solution

  • Try this

    MATCH (a:A)-[i:INCLUDES]-(b:B) RETURN i, a, b;