-
Notifications
You must be signed in to change notification settings - Fork 161
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
Node references are visited on unpredictable order leading to unsaved changes. #407
Comments
Hi, thank you for reporting this. Just quick follow up question to make sure I understand this correctly. In your example graph situation "Sample place" should be stored for depth 3 no matter what, right? So your suggested solution |
Hi! Thanks for the quick reply! That would be the perfect world I guess... Yes it could follow the red one, but at least the behavior is consistent and prevents the "it was working yesterday". About the example, I noticed that I added an extra relationship ( I really can't think of a satisfy all solution, even don't feel sure would be feasible, but I believe the important point in this case is to have a consistent behavior so at least the save operation is always wrong or always right. |
When a node is reached at horizon 0 it is marked as visited. After reaching the node again, with horizon >0 its relationships should be visited. This commit stores the horizon in CypherContext and uses it to evaluate if the traversal should continue. Fixes #407.
When a node is reached at horizon 0 it is marked as visited. After reaching the node again, with horizon >0 its relationships should be visited. This commit stores the horizon in CypherContext and uses it to evaluate if the traversal should continue. Fixes #407.
* Solves a problem when deep saving an entity which is reachable from several paths. When a node is reached at horizon 0 it is marked as visited. After reaching the node again, with horizon >0 its relationships should be visited. This commit stores the horizon in CypherContext and uses it to evaluate if the traversal should continue. Fixes #407. * Fix mapping of directed transient relationships defined in both directions
Expected Behavior
I would expect to OGM visit nodes in a graph always in the same order between distinct executions.
Current Behavior
The visiting order changes between executions, leading to unsaved changes.
Possible Solution
The order changes due to the following observations:
EntityGraphMapper
is visiting nodes randomly between executions in a graph when saving with limited depth.EntityGraphMapper.mapEntityReferences
finds references iterating over a collection based on whatClassInfo.relationshipFields
returns.ClassInfo.relationshipFields
returns a newly createdHashSet
based onFieldInfo
class that stores the fields in aHashMap
the order of the collection is not guaranted which leads to problems when using limited depth operations.Use collections that guarantee the same order of iteration between executions in the places noted above.
Steps to Reproduce (for bugs)
Quite hard to reproduce as it depends on many factors related to environment or uncontrolled.
Context
This problem was noticed while working with limited depth save operations. When following the unexpected visiting order some changes were simply ignored.
By debugging and unit testing was possible to see that the
EntityGraphMapper.mapEntityReferences
iterated over collections with distinct sequences leading to some nodes being ignored as they were partially visited.Example situation:
Saving from the node labeled as
Start
with depth3
there's two possible visiting sequence (blue and red), one would expect to only one of them always take place but not randomly switching between.In case the red sequence is applied, changes to the purple node would not be persisted.
Note:
TASK_TO_BAG
relationship should not be considered!Your Environment
Edit: Adding note to the graph
The text was updated successfully, but these errors were encountered: