Skip to content

Relation mapping using the most abstract label #2459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marichka-spin opened this issue Dec 15, 2021 · 7 comments
Closed

Relation mapping using the most abstract label #2459

marichka-spin opened this issue Dec 15, 2021 · 7 comments
Assignees
Labels
type: bug A general bug

Comments

@marichka-spin
Copy link

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

Thank you for the assistance!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 15, 2021
@meistermeier meistermeier self-assigned this Dec 16, 2021
@marichka-spin
Copy link
Author

I've created test project to reproduce the issue https://github.com/idun-corp/neo4j-test
Everything works using only embedded Neo4jDB

@meistermeier meistermeier added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 22, 2021
@meistermeier
Copy link
Collaborator

Thanks for spotting this. I thought that I did something to avoid the override. Must have been wrong ;)

@marichka-spin
Copy link
Author

No problem! Looking forward to the fix! Wish you Merry Christmas and happy holidays

@meistermeier
Copy link
Collaborator

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
Copy link
Author

@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
Copy link
Collaborator

Great, thanks for the feedback.
Of course we are interested in the issues, you have to report.

@marichka-spin
Copy link
Author

@meistermeier Thank you! Finally I've finished testing the new fix! Looks good! Looking forward for release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants