(same question was posted on StackOverflow 7 days ago: Spring Data Neo4j 6: findAll() operation doesn't map relationships properly - Stack Overflow)
In Spring Data Neo4j 6 (6.0.1), a basic Neo4jTemplate findAll() operation with a simple relationship doesn't seem to map the relationship entity and its target even though they are part of the result set. Is this a bug or am I missing something?
Let's consider the following basic scenario:
var a = new EntityA();
var b = new EntityB();
a.entityB = b;
neo4jTemplate.save(a);
with
@Node
public class EntityA {
@Id @GeneratedValue(UUIDStringGenerator.class)
public String id;
@Relationship("HAS_ENTITY_B")
public EntityB entityB;
}
@Node
public class EntityB {
@Id @GeneratedValue(UUIDStringGenerator.class)
public String id;
}
When trying to map a result like this:
var result = neo4jTemplate.findAll("MATCH (a:EntityA)-[r:HAS_ENTITY_B]->(b:EntityB) RETURN a,r,b", EntityA.class);
Assert.notNull(result.get(0).entityB, "entityB should not be null here!");
I would expect the entityB property not to be null.