-
Notifications
You must be signed in to change notification settings - Fork 162
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
Mapping of nodes and relations returned as lists or maps #737
Comments
I wonder if that is related to #666. Could you please test if your issues was there in 3.2.3 respectively 3.1.15? |
I don't think this is related to #666 because here (#737) it's a even a step before the actual wiring of @NodeEntity. Consider the case that In a nutshell, this issue is about OGM mapping "list of nodes" correctly but not "list of list of nodes" or "list of maps containing nodes" in query results. Btw my demo project for reproduction uses OGM 3.2.3. |
I cannot reproduce that issue in current 3.2 and master. I have attached an updated version of your demo project, that uses Neo4j-OGM 3.2.4 and it runs as well ( See my article here if you need help upgrading Spring managed versions in you projects: https://michael-simons.github.io/simple-meetup/overriding-spring-managed-versions-in-gradle-projects. Thanks for reporting. |
For the record: Also fixed in Neo4j-OGM 3.1.16 (see |
Thanks! In fact, it is working with OGM version 3.2.4, so I will update. And thanks for the spring boot dependency tip, I didn't know it was that easy to adapt the version. |
If you can wait till tomorrow, we will have 3.2.6 out. It fixes a performance and spring boot dev tools issue. The upgrade with Maven is similar (use Maven properties in the Thanks for your feedback, much appreciated. |
@michael-simons, is that intented that the query
will return only the relation Tested with 3.2.6. |
If we encounter a list result that contains relationships and nodes from a pattern comprehension both types of object will get bundled into the OGM result.
Thanks to the awesome @meistermeier I understood your problem better and we fixed that, too (and yes, we do think that this is a bug). |
Great news, so this will be included in 3.2.7? |
If we encounter a list result that contains relationships and nodes from a pattern comprehension both types of object will get bundled into the OGM result.
Yep. |
This fixes #902 in a similar fashion to what 0ba80b1 did for #821. While #821 was fixed for non-domain objects as the `handle` method of the `RestModelMapper.ResultRowBuilder` calls `convertToTargetContainer which itself works recursively on non-domain objects, such an implicit fix wasn't applied to domain objects. As the domain objects are all flattened into the in-memory graph model the hierarchy (parents and siblings) of nested lists must be stored inside the `RestModelMapper`. This is achivied by a `Map<String, List<String>>`, basically a nested list of pointers. This map is used to recreate the shape of the original query. This had some affects on the `SingleUseEntityMapper`: It may run into a list of already mapped objects now, so those need some special treatment, similar to queries such as mentioned in #737 (especially queries containing and returning pattern comprehension without extracting nodes and relationsships): They will work as before and contain the mapped objects, but in the same fashion the pattern comprehension produced them: In a list.
Hello @steffen-harbich-cognitum Here's a heads up for you: in #902 it was discovered that we flatten lists of known objects which shouldn't be the case as we don't do this for non-domain objects. We are gonna fix that, but for your example it means a breaking change:
with the array around it, it will map to a List of node and relationships as it is actually correct (that's what a pattern comprehension produces). A workaround to not change your calling code will be
the mapping itself won't change. Otherwise, the calling / usage side need a bit of change: It must now get the first index of the created pattern. See Lines 955 to 969 in 60e5f51
Thank you and sorry for any possible inconvenience. |
This fixes #902 in a similar fashion to what 0ba80b1 did for #821. While #821 was fixed for non-domain objects as the `handle` method of the `RestModelMapper.ResultRowBuilder` calls `convertToTargetContainer which itself works recursively on non-domain objects, such an implicit fix wasn't applied to domain objects. As the domain objects are all flattened into the in-memory graph model the hierarchy (parents and siblings) of nested lists must be stored inside the `RestModelMapper`. This is achivied by a `Map<String, List<String>>`, basically a nested list of pointers. This map is used to recreate the shape of the original query. This had some affects on the `SingleUseEntityMapper`: It may run into a list of already mapped objects now, so those need some special treatment, similar to queries such as mentioned in #737 (especially queries containing and returning pattern comprehension without extracting nodes and relationsships): They will work as before and contain the mapped objects, but in the same fashion the pattern comprehension produced them: In a list.
Alright, thanks for info. I will keep that in mind when we update. |
Expected Behavior
Consider the following query:
I would expect OGM to map
n2
to its @NodeEntity object and wire relations accordingly. Alternatives:Current Behavior
None of the above queries is mapping the node
n2
when callingsession.query("...", Map.of(), true)
.Possible Solution
If adapted to
then it works but IMO this is an unnecessary repitition of the pattern comprehension. Please also note that the cypher generated by OGM when calling
session.load
has the same pattern as the first alternative query from above which implied my assumption that it should work.Steps to Reproduce (for bugs)
Simple example project reproducing the issue:
demo.zip
Start gradle task :test in debug mode to fail the assertion, important code lines in
NodeService
class.Context
See https://stackoverflow.com/questions/59481997 for background information.
Your Environment
The text was updated successfully, but these errors were encountered: