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
{{ message }}
Repository navigation
Relation mapping using the most abstract label #2459
Hello again team :)
I continue working over migrating our code to the new Spring Data. And currently I'm testing version 6.2.1-SNAPSHOT. Lets consider the case:
@Node("PetOwner")
public abstract class PetOwner {
@Relationship(type = "hasPet")
private List<Animal> pets;
}
@Node("Boy")
public class Boy extends PetOwner {}
@Node("Girl")
public class Girl extends PetOwner {}
@Node("Animal")
public abstract class Animal {}
@Node("Dog")
public class Dog extends Animal {}
@Node("Cat")
public class Cat extends Animal {}
So lets consider that Neo4j DB has Node(Boy) that has 1 relation to 1 Cat and 1 relation to 1 Dog, I assumed that projection view that looks like below should work and should result List pets with size 2 but results with NULL: RETURN petOwner1{.*, PetOwner_hasPet_Animal | [....]}
But what I observed in DefaultNeo4jEntityConverter class (lines 349-354) relation mapping is executed in two phases using abstract source label and using concrete source label. During first phase PetOwner_hasPet_Animal is mapped well but during next phase mapped values are overwritten with empty ArrayList. MapAccessor values (line 542) doesn't contain key "Boy_hasPet_Animal" and empty collection is instantiated (line 658). https://github.com/spring-projects/spring-data-neo4j/blob/6.2.x/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jEntityConverter.java
There will be a little early Christmas present available for you with version 6.2.1-GH-2459-SNAPSHOT. 🎁
But Santa's elves are still working on this, it should arrive in ~30 minutes and Santa would be thankful for feedback 🎅
Thanks 😉
@meistermeier thank you for the fix. I'm still testing. Are you interested in other issues I may notice during my work? Anyway I'm using neo4j and Neo4j Spring Data actively.
Activity
marichka-spin commentedon Dec 16, 2021
I've created test project to reproduce the issue https://github.com/idun-corp/neo4j-test
Everything works using only embedded Neo4jDB
meistermeier commentedon Dec 22, 2021
Thanks for spotting this. I thought that I did something to avoid the override. Must have been wrong ;)
marichka-spin commentedon Dec 22, 2021
No problem! Looking forward to the fix! Wish you Merry Christmas and happy holidays
GH-2459 - Prepare branch.
GH-2459 - Avoid overriding when mapping relationships with abstract t…
meistermeier commentedon Dec 22, 2021
There will be a little early Christmas present available for you with version
6.2.1-GH-2459-SNAPSHOT. 🎁But Santa's elves are still working on this, it should arrive in ~30 minutes and Santa would be thankful for feedback 🎅
Thanks 😉
marichka-spin commentedon Dec 23, 2021
@meistermeier thank you for the fix. I'm still testing. Are you interested in other issues I may notice during my work? Anyway I'm using neo4j and Neo4j Spring Data actively.
meistermeier commentedon Dec 23, 2021
Great, thanks for the feedback.
Of course we are interested in the issues, you have to report.
GH-2459 - Avoid overriding when mapping relationships with abstract t…
GH-2459 - Avoid overriding when mapping relationships with abstract t…
marichka-spin commentedon Dec 23, 2021
@meistermeier Thank you! Finally I've finished testing the new fix! Looks good! Looking forward for release!
spring-projectsGH-2459 - Avoid overriding when mapping relationships …