-
Notifications
You must be signed in to change notification settings - Fork 166
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
Relation that is not modeled via annotations is filled into NodeEntity #666
Comments
That is not a bug but desired (and undocumented) fallback behaviour. neo4j-ogm/core/src/main/java/org/neo4j/ogm/metadata/reflect/EntityAccessManager.java Lines 361 to 368 in 72f5b69
I leave this issue open to discuss this internally if we want to keep this or, for example, introduce something like a strict mapping mode where this will fail. Thanks for your time to create the example. |
I think the FWIW: I also do think that this - while intended as might have been - is very close to a bug. Some sort of surprises you don't want to have. |
…related nodes. The entity access manager tries several ways to find a field for mapping relationships. Usually, more than 3 tries are necessary for custom queries. The last approach just checks if there is any field of the same type as a currently mapped relationship and just dumps the relationships content into it. This is bad in case when the field type matches but there’s actually an annotation contradicting it. This commit makes the entity access manager check for contradicting annotations and if there is one, doesn’t fill in the object. This fixes #666.
It will be my pleasure to fix issue number 666. We don't fill in the relationship anymore as soon as there's a contradicting annotation. That just doesn't make any sense. Good thing is: There are no tests for exactly that behaviour and I won't have to argue about that. If you remove the annotation Waiting for all tests to go green before this will make it's way over all the branches we currently support. |
…related nodes. The entity access manager tries several ways to find a field for mapping relationships. Usually, more than 3 tries are necessary for custom queries. The last approach just checks if there is any field of the same type as a currently mapped relationship and just dumps the relationships content into it. This is bad in case when the field type matches but there’s actually an annotation contradicting it. This commit makes the entity access manager check for contradicting annotations and if there is one, doesn’t fill in the object and thus fixes #666.
…related nodes. The entity access manager tries several ways to find a field for mapping relationships. Usually, more than 3 tries are necessary for custom queries. The last approach just checks if there is any field of the same type as a currently mapped relationship and just dumps the relationships content into it. This is bad in case when the field type matches but there’s actually an annotation contradicting it. This commit makes the entity access manager check for contradicting annotations and if there is one, doesn’t fill in the object. This is a backport of 0a9a921.
Please see the following demo project.
demo.zip
Expected Behavior
Excerpt from test:
A relation that is not modeled in NodeEntities should not be filled into a NodeEntity when querying that relation/related node.
Current Behavior
Not-modeled related object is filled into the returned object.
Possible Solution
Feels like OGM doesn't check the @relationship "type" in that case but considers only types or something.
When actually modeling the un-modeled relation then bahavior of OGM is correct. But this is not viable in our case.
Steps to Reproduce (for bugs)
Context
Our graph data is not completely modeled in Java objects.
Your Environment
The text was updated successfully, but these errors were encountered: