-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#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.
- Loading branch information
1 parent
7be19d3
commit bfcadad
Showing
7 changed files
with
371 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
test/src/test/java/org/neo4j/ogm/domain/gh640/MyNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.ogm.domain.gh640; | ||
|
||
import static org.neo4j.ogm.annotation.Relationship.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.neo4j.ogm.annotation.GeneratedValue; | ||
import org.neo4j.ogm.annotation.Id; | ||
import org.neo4j.ogm.annotation.NodeEntity; | ||
import org.neo4j.ogm.annotation.Relationship; | ||
|
||
/** | ||
* @author Michael J. Simons | ||
*/ | ||
@NodeEntity | ||
public class MyNode { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
private String name; | ||
|
||
@Relationship(type = "REL_ONE", direction = INCOMING) | ||
private MyNode refOne; | ||
|
||
@Relationship(type = "REL_TWO", direction = UNDIRECTED) | ||
private List<MyNode> refTwo = new ArrayList<>(); | ||
|
||
public MyNode(String name) { | ||
this.name = name; | ||
} | ||
|
||
public MyNode() { | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public MyNode getRefOne() { | ||
return refOne; | ||
} | ||
|
||
public void setRefOne(MyNode refOne) { | ||
this.refOne = refOne; | ||
} | ||
|
||
public List<MyNode> getRefTwo() { | ||
return refTwo; | ||
} | ||
|
||
public void setRefTwo(List<MyNode> refTwo) { | ||
this.refTwo = refTwo; | ||
} | ||
|
||
public MyNode copy() { | ||
MyNode n = new MyNode(); | ||
n.id = id; | ||
n.name = name; | ||
n.setRefOne(refOne); | ||
n.setRefTwo(refTwo); | ||
return n; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
MyNode myNode = (MyNode) o; | ||
return Objects.equals(id, myNode.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override public String toString() { | ||
return "MyNode{" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
test/src/test/java/org/neo4j/ogm/domain/gh640/MyNodeWithAssignedId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (c) 2002-2019 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.ogm.domain.gh640; | ||
|
||
import static org.neo4j.ogm.annotation.Relationship.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.neo4j.ogm.annotation.GeneratedValue; | ||
import org.neo4j.ogm.annotation.Id; | ||
import org.neo4j.ogm.annotation.NodeEntity; | ||
import org.neo4j.ogm.annotation.Relationship; | ||
|
||
/** | ||
* @author Michael J. Simons | ||
*/ | ||
@NodeEntity | ||
public class MyNodeWithAssignedId { | ||
|
||
@Id | ||
private String name; | ||
|
||
@Relationship(type = "REL_ONE", direction = INCOMING) | ||
private MyNodeWithAssignedId refOne; | ||
|
||
@Relationship(type = "REL_TWO", direction = UNDIRECTED) | ||
private List<MyNodeWithAssignedId> refTwo = new ArrayList<>(); | ||
|
||
public MyNodeWithAssignedId(String name) { | ||
this.name = name; | ||
} | ||
|
||
public MyNodeWithAssignedId() { | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public MyNodeWithAssignedId getRefOne() { | ||
return refOne; | ||
} | ||
|
||
public void setRefOne(MyNodeWithAssignedId refOne) { | ||
this.refOne = refOne; | ||
} | ||
|
||
public List<MyNodeWithAssignedId> getRefTwo() { | ||
return refTwo; | ||
} | ||
|
||
public void setRefTwo(List<MyNodeWithAssignedId> refTwo) { | ||
this.refTwo = refTwo; | ||
} | ||
|
||
public MyNodeWithAssignedId copy() { | ||
MyNodeWithAssignedId n = new MyNodeWithAssignedId(); | ||
n.name = name; | ||
n.setRefOne(refOne); | ||
n.setRefTwo(refTwo); | ||
return n; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
MyNodeWithAssignedId myNode = (MyNodeWithAssignedId) o; | ||
return Objects.equals(name, myNode.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name); | ||
} | ||
|
||
@Override public String toString() { | ||
return "MyNodeWithAssignedId{" + | ||
"name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.