You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using SDN and Neo4j a lot in my project and everything was fine so far, but recently I've encountered strange behaviour. Basically, I created a model consisting of 3 entities connected in the chain: A -rel1-> B -rel2-> C. I added the default Spring Neo4j repository for A entity, filled the database and tried to call aRepository.findAll(). I obtained the result: A -rel1-> B -rel2-> null, C was missing.
It took me several hours to find the root of this problem. Everything was stored correctly in the DB, generated queries looked correct, and the C object was returned in the json results. But somehow it was lost in mapping to the object model. Eventually, I realized it was a problem with the model structure. Class B extends another class, which is abstract. While digging with the debugger I found DefaultNeo4jPersistentEntity#getMostAbstractParent() method which is used to generate key describing data in the mapping process. When an entity has an abstract parent, the relation is resolved as "parent_rel_C" instead of "B_rel_C" (which is the real key in the returned data!).
Moreover, when I load the relationship more directly, by B repository, C is loaded as intended, because an abstract parent is not searched when you process the main entity (this is returned in the aforementioned getMostAbstractParent()).
I think that's the cause of my problem, but I still don't understand why it works that way (and didn't find a mention of it in the documentation). Or maybe it's just a bug. I don't know, but would be grateful for clarification and advice what to do. :)
If you remove the abstract modifier from the BParent class, the test passes.
I'm using Spring Boot 2.7.8 with Neo4j starter (SDN 6.3.7). I wasn't able to check it in the newer versions of the SDN because of some compatibility issues with newer Spring, but at least DefaultNeo4jPersistentEntity code seems unchanged when I checked.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this and sorry for missing it in the first place.
I am pretty sure it is related to #2819 Basically the same problem here but without the use of projections.
There is a fix mentioned in the issue: 6.3.14-GH-2819-SNAPSHOT
or, if you on a newer version 7.2.0-GH-2819-SNAPSHOT
will close this issue now and try to keep the focus on the linked on for feedback.
I'm using SDN and Neo4j a lot in my project and everything was fine so far, but recently I've encountered strange behaviour. Basically, I created a model consisting of 3 entities connected in the chain:
A -rel1-> B -rel2-> C
. I added the default Spring Neo4j repository forA
entity, filled the database and tried to callaRepository.findAll()
. I obtained the result:A -rel1-> B -rel2-> null
,C
was missing.It took me several hours to find the root of this problem. Everything was stored correctly in the DB, generated queries looked correct, and the
C
object was returned in the json results. But somehow it was lost in mapping to the object model. Eventually, I realized it was a problem with the model structure. ClassB
extends another class, which is abstract. While digging with the debugger I foundDefaultNeo4jPersistentEntity#getMostAbstractParent()
method which is used to generate key describing data in the mapping process. When an entity has an abstract parent, the relation is resolved as "parent_rel_C" instead of "B_rel_C" (which is the real key in the returned data!).Moreover, when I load the relationship more directly, by
B
repository,C
is loaded as intended, because an abstract parent is not searched when you process the main entity (this
is returned in the aforementionedgetMostAbstractParent()
).I think that's the cause of my problem, but I still don't understand why it works that way (and didn't find a mention of it in the documentation). Or maybe it's just a bug. I don't know, but would be grateful for clarification and advice what to do. :)
I've created a small example of the problem:
If you remove the
abstract
modifier from theBParent
class, the test passes.I'm using Spring Boot 2.7.8 with Neo4j starter (SDN 6.3.7). I wasn't able to check it in the newer versions of the SDN because of some compatibility issues with newer Spring, but at least
DefaultNeo4jPersistentEntity
code seems unchanged when I checked.The text was updated successfully, but these errors were encountered: