Skip to content
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

Odd behavior with multiple relations to same node type #640

Closed
steffen-harbich-cognitum opened this issue Jun 28, 2019 · 1 comment
Closed
Assignees

Comments

@steffen-harbich-cognitum

Expected Behavior

Please see my minimal example project demo.zip and run the test. On an node entity, I changed a relation and it was not written to DB as expected when calling save method.

Current Behavior

Excerpt from my node entity:

@NodeEntity
public class MyNode {
...
    @Relationship(type = "REL_ONE", direction = INCOMING)
    private MyNode refOne;

    @Relationship(type = "REL_TWO", direction = UNDIRECTED)
    private List<MyNode> refTwo = new ArrayList<>();
...
    public MyNode copy() {...}
...
}

If I change the "refTwo" relation direction to OUTGOING, then it is working but I really need to have undirected relation there.

Also if I do not use a copy of the node entity, then it is working, too (with UNDIRECTED relation). Although the copy is not required in the simple example, in my real application the copy is required because I change the node entity, do some queries that yield the node entity and save finally. If I wouldn't copy the node entity then the queries would overwrite the changed data.

Possible Solution

Steps to Reproduce (for bugs)

Call the :test task of the supplied demo project in debug mode (e.g. use IntelliJ) such that "assert" will trigger. Test will fail in line 62 of NodeService class because the relation changed before was not written to neo4j.

Context

Your Environment

  • OGM Version used: 3.1.11
  • Java Version used: 11
  • Neo4J Version used: 3.5
  • Operating System and Version: Win/Ubuntu
@michael-simons michael-simons self-assigned this Jul 2, 2019
michael-simons added a commit that referenced this issue Jul 2, 2019
This change tries to store visited nodes under their native graph id in the compile context if possible. Thus, they are recognized even when a user uses a different instance of the same entity for persisting state.

This fixes #640.
michael-simons added a commit that referenced this issue Jul 2, 2019
…#642)

This change tries to store visited nodes under their native graph id in the compile context if possible. Thus, they are recognized even when a user uses a different instance of the same entity for persisting state.

This fixes #640.
@michael-simons
Copy link
Collaborator

Thank you for your report and the example project.

I could reproduce the issue and this is fixed for 3.2 and and 3.1.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants