-
Notifications
You must be signed in to change notification settings - Fork 617
Object mapping does not work correctly with abstract superclass and recursion #2138
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
Comments
Hey, I have the same problem after trying to create an abstract class for what in principle was a concrete class
If I do territoryRepository.findAll() every object is of the same type, even though I have some nodes of type Continent and others of type Country Even more so, If I try to update a Country adding one item to its relationshipList it throws a org.springframework.dao.DataIntegrityViolationException |
I've also ran into this with a similar setup to OP. It kind of seems that the concrete implementation that is used is random, as opposed to being based on the actual, primary label (label 0) on the node in the DB. |
Thanks for reporting this. We are currently investigating the problem. I can confirm that this is a bug. |
In a few minutes a 6.0.6-GH-2138-SNAPSHOT will appear in the snapshot repositories of Spring. |
Respect class hierachy when querying for and mapping to generic classes. This commit closes GH-2138.
Since our internal tests went also fine for this, it is now available as 6.0.6-SNAPSHOT and will be part of the next patch round. Again, thanks for reporting this and all your feedback. |
Just updated to Spring Boot 2.4.4, and this is still broken. I am not getting the correct concrete implementation back, and have failing tests. This issue outlines mostly what my domain model looks like. #2176 |
Hi, I'm using the version 6.0.3 of Spring Data Neo4j and I have a problem with retrieving a simple data structure with an abstract superclass and recursion. The problem is, that the objects are not mapped to their correct type.
This is the model:
The data structure I've created is
Building -IS_CHILD-> Site -IS_CHILD-> Company
I have defined a BuildingRepository:
When I retrieve the building with the
findById
, the building is retrieved correctly. However, its parent is incorrectly mapped as a building, and the parent of this is incorrectly mapped as a site (in all cases the name-field is mapped correctly).Expected Behavior:
I expect buildingRepository.findById() to return the building with its correctly mapped parent, and their correctly mapped parent etc.
Actual Behavior:
The parent of the building and the parent of this parent are not mapped to the correct type. I think it has something to do with the labels; when instantiating the parent, the labels of the sourcenode are being used to derive the concrete node description for the parent.
The text was updated successfully, but these errors were encountered: