-
Notifications
You must be signed in to change notification settings - Fork 617
Persistence logic bails out on the wrong combination of source and relationship. #2289
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
The problem in your constellation is that you describe a bidirectional relationship just partially.
This ^^ defines the bidirectional dependency. Every relationship in the graph will get mapped either outgoing or incoming.
Will only set the (outgoing) relationship on this When Spring Data Neo4j starts to persist What might look like something we could add as a "relaxed" bidirectional definition is more complex when you look more closely. SDN cannot determine who is right in this constellation. Is it For this to solve you would have to also do something similar to If there is something unclear (or I misunderstood anything), please ask, otherwise you can also close this issue ;) |
I'm not sure I fully understand why "SDN cannot determine who is right in this constellation." When I create a relation from
By this, do you mean I have to add an incoming relationship to Originally, I was also hoping that the |
Ah, after looking at the other issues I see you're saying that I should add an incoming relationship to Last question: Upon persisting the sku with the relationship, Edit: Upon trying it out, adding the same relationship to Edit 2: Even though it doesn't make logical sense, it still works. I just have to hydrate |
SDN does not take SDN will automatically process the relationship from a to b. In the graph will only be one relationship in the end. Most important thing is: because the relationship back to For edit2: Yes, this is a side effect. Usually I try to advice against bidirectional relationships at all (within Spring Data). That's the reason why the |
Sorry, @meistermeier but I was mistaken. It only appeared to work because I got lucky 5+ times. The behavior is still the same even when adding the relation to the
I also tried making two separate relationship objects with the correct
I assume if Spring decides to look at outgoing relations last, then saving |
Hi. The last snippet you added @BenBohannon is the one I personally would use and we would recommend. That it doesn't work is a bug. Why doesn't it work? You are right in your assumption it is about ordering: Sometimes we get the properties in different order from Spring Data Commons, that is a given. This will be fixed at least in 6.1.x, but we try to back port it to 6.0.x, too. Thanks for your report and the discussion. |
…onships. The previous check used the obverse combined with the fromId to check if traversal can be stopped or not. This is wrong, we would need to combine obverse with targetId, which we may not have at the moment. This change simplifies the check and only looks at visited relationships from source to somewhere else to avoid additional rounds. This fixes #2289.
…onships. The previous check used the obverse combined with the fromId to check if traversal can be stopped or not. This is wrong, we would need to combine obverse with targetId, which we may not have at the moment. This change simplifies the check and only looks at visited relationships from source to somewhere else to avoid additional rounds. This fixes #2289.
Hi @BenBohannon Would you be willing to try out our snapshot build? This bug is fixed in We publish snapshots at <repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories> See
Please let us know if there's more we have overseen. |
I tried snapshot build 6.0.10, and it's closer but seems to behave strangely. In the same test from above:
the first save on I can't get 6.1.2-SNAPSHOT or 6.2.0-SNAPSHOT to correctly load the repository beans to test them. |
Thanks @BenBohannon we can reproduce this and investigate further. |
I'm having difficulty with SDN frequently not persisting relationships between nodes upon calling
.save()
. Saving Nodes to the DB works as expected, but relationships do not appear to be written. Below is an example test that has the issue, along with the node and relationship classes.Looking through the neo4j web console, the nodes are persisted without relations. Through the debugger, the relationships are in the
rangeRelationsOut
Sets ofa
andb
nodes, but the relationship'sid
is null (which should be autogenerated on save).The most unusual part of this is that it works sometimes. I can re-run the same test without changes, and it will either persist ALL relationships or not persist ANY relationships. I haven't seen any cases where it persists some relationships but not others.
I've seen the same behavior when running the Spring app locally (not tests), but still using the "neo4j:4.2.3" docker container for neo4j. The only fix is to repeatedly restart the Spring app until it decides to work.
Test:
Node:
Relationship:
Repository:
The text was updated successfully, but these errors were encountered: