Open abccbaandy opened 3 months ago
The person1Repository
will query for :Parent1_CONTAIN
nodes defined by parent1Relationships
in Parent1
.
Those relationships are of type BaseNode
. The next iteration will than query for :Parent2_CONTAIN
and :Parent1_CONTAIN
defined in Parent2
and Parent1
as the implementations of BaseNode
.
This behaviour is expected.
Looking at the other issue and the Child
typed relationship, the same behaviour applies because the type definition is derived from the class public class BaseDbRelationship<T extends BaseNode>
itself which is again "just" a BaseNode
.
The
person1Repository
will query for:Parent1_CONTAIN
nodes defined byparent1Relationships
inParent1
. Those relationships are of typeBaseNode
. The next iteration will than query for:Parent2_CONTAIN
and:Parent1_CONTAIN
defined inParent2
andParent1
as the implementations ofBaseNode
. This behaviour is expected.Looking at the other issue and the
Child
typed relationship, the same behaviour applies because the type definition is derived from the classpublic class BaseDbRelationship<T extends BaseNode>
itself which is again "just" aBaseNode
.
I can guess this behavior, but I think the design is wrong.
When I query parent1, SDN should search for Parent1_CONTAIN
relationship only.
But I think the root cause is SDN treat the BaseNode as a Node
.
In my domain, I don't really use the BaseNode, it just a base class for share common field and polymorphism.
In real case, I have many childes with same relationship type:
(:Parent1)-[r:Parent1_CONTAIN]->(:Child1)
(:Parent1)-[r:Parent1_CONTAIN]->(:Child2)
So, I have to use a base class to get all of them.
@Relationship(type = "Parent1_CONTAIN", direction = Relationship.Direction.OUTGOING)
private List<BaseRelationship<BaseNode>> parent1Relationships;
@meistermeier Is there any other way to achieve this requirement without base class issue?
Any update? @michael-simons
I have some node
When I get parent1 with find all:
The log shows
In the query log, shows it search for
Parent2_CONTAIN
but it shouldn't, becauseParent2_CONTAIN
is not in Parent1 node. In real case, if I have 10 node extends the base node, it will end up query all 10 node's relationship, I think it is a performance issue.Change to
Child
still have this issueAlso, I think this issue is associate https://github.com/spring-projects/spring-data-neo4j/issues/2933