I have 2 users in my neo4j DB: enter image description here
here are my node objects:
@Node
public class User {
@Id
@GeneratedValue
private Long id;
@Property("user_id")
private Long userId;
@Property("name")
private String name;
@Relationship(type = "HAS_ACCESS", direction = Relationship.Direction.OUTGOING)
public List<HasAccessRelation> relation;
}
@AllArgsConstructor
@NoArgsConstructor
@RelationshipProperties
public class HasAccessRelation {
@RelationshipId
private Long id;
private String type;
@TargetNode
private Folder folder;
}
@Node
public class Folder {
@Id
@GeneratedValue
private Long id;
@Property("folder_id")
private Long folderId;
@Property("owner_user_id")
private Long ownerUserId;
@Property("name")
private String name;
@Relationship(type = "HAS_ACCESS", direction = Relationship.Direction.OUTGOING)
public List<HasAccessRelation> relations = new ArrayList<>();
}
When I delete list of HasAccessRelation in my Folder class - everything works as expected, my User repository findAll method returns users with HAS_ACCESS relations and inside these relations I have my folders. But I want to return all folder structures that the user has (deep graph with bigger depth). So I added list of relations to my Folder Node object and it stopped working. The exception I'm getting:
org.neo4j.driver.exceptions.DatabaseException: Expected
RegularSinglePlannerQuery(QueryGraph {Nodes: [' rootNodeIds@7'], Predicates: ['id(` rootNodeIds@7`) IN $rootNodeIds']},InterestingOrder(RequiredOrderCandidate(List()),List()),AggregatingQueryProjection(Map(),Map(n -> FunctionInvocation(Namespace(List()),FunctionName(collect),false,Vector(Variable( rootNodeIds@7)))),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['n'], Optional Matches: : ['QueryGraph {Rels: ['( UNNAMED105)--[relationshipIds]--( UNNAMED126)'], Predicates: ['id(relationshipIds) IN $relationshipIds']}']},InterestingOrder(RequiredOrderCandidate(List()),List()),AggregatingQueryProjection(Map(n -> Variable(n)),Map(__sr__ -> FunctionInvocation(Namespace(List()),FunctionName(collect),true,Vector(Variable(relationshipIds)))),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['__sr__', 'n'], Optional Matches: : ['QueryGraph {Nodes: ['relatedNodeIds'], Predicates: ['id(relatedNodeIds) IN $relatedNodeIds']}']},InterestingOrder(RequiredOrderCandidate(List()),List()),AggregatingQueryProjection(Map(n -> Variable(n), __sr__ -> Variable(__sr__)),Map(__srn__ -> FunctionInvocation(Namespace(List()),FunctionName(collect),true,Vector(Variable(relatedNodeIds)))),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['__sr__', '__srn__', 'n']},InterestingOrder(RequiredOrderCandidate(List()),List()),UnwindProjection( rootNodeIds@384,Variable(n)),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: [' rootNodeIds@384', '__sr__', '__srn__', 'n']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(user -> Variable( rootNodeIds@384), __sr__ -> Variable(__sr__), __srn__ -> Variable(__srn__)),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['__sr__', '__srn__', 'user']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(__sn__ -> Variable(user), __sr__ -> Variable(__sr__), __srn__ -> Variable(__srn__)),QueryPagination(None,None),Selections(Set())),None,None)),None)),None)),None)),None)),None)
Instead, got:
RegularSinglePlannerQuery(QueryGraph {Nodes: [' rootNodeIds@7'], Predicates: ['id(` rootNodeIds@7`) IN $rootNodeIds']},InterestingOrder(RequiredOrderCandidate(List()),List()),AggregatingQueryProjection(Map(),Map(n -> FunctionInvocation(Namespace(List()),FunctionName(collect),false,Vector(Variable( rootNodeIds@7)))),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['n'], Optional Matches: : ['QueryGraph {}']},InterestingOrder(RequiredOrderCandidate(List()),List()),AggregatingQueryProjection(Map(n -> Variable(n)),Map(__sr__ -> FunctionInvocation(Namespace(List()),FunctionName(collect),true,Vector(Variable(relationshipIds)))),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['__sr__', 'n'], Optional Matches: : ['QueryGraph {Nodes: ['relatedNodeIds'], Predicates: ['id(relatedNodeIds) IN $relatedNodeIds']}']},InterestingOrder(RequiredOrderCandidate(List()),List()),AggregatingQueryProjection(Map(n -> Variable(n), __sr__ -> Variable(__sr__)),Map(__srn__ -> FunctionInvocation(Namespace(List()),FunctionName(collect),true,Vector(Variable(relatedNodeIds)))),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['__sr__', '__srn__', 'n']},InterestingOrder(RequiredOrderCandidate(List()),List()),UnwindProjection( rootNodeIds@384,Variable(n)),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: [' rootNodeIds@384', '__sr__', '__srn__', 'n']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(user -> Variable( rootNodeIds@384), __sr__ -> Variable(__sr__), __srn__ -> Variable(__srn__)),QueryPagination(None,None),Selections(Set())),Some(RegularSinglePlannerQuery(QueryGraph {Arguments: ['__sr__', '__srn__', 'user']},InterestingOrder(RequiredOrderCandidate(List()),List()),RegularQueryProjection(Map(__sn__ -> Variable(user), __sr__ -> Variable(__sr__), __srn__ -> Variable(__srn__)),QueryPagination(None,None),Selections(Set())),None,None)),None)),None)),None)),None)),None)
Plan: ProduceResult(List(__sn__, __sr__, __srn__)) {
Could someone please help me to figure out what I'm doing wrong?