-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-666 - Check for contradicting annotations before mapping possible …
…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.
- Loading branch information
1 parent
8c47d6b
commit ec708d6
Showing
8 changed files
with
232 additions
and
19 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
50 changes: 50 additions & 0 deletions
50
test/src/test/java/org/neo4j/ogm/domain/gh666/MessedUpNode1.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,50 @@ | ||
/* | ||
* 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.gh666; | ||
|
||
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 MessedUpNode1 { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
@Relationship(type = "RELATION_A") | ||
private MessedUpNode2 ref; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public MessedUpNode2 getRef() { | ||
return ref; | ||
} | ||
|
||
public void setRef(MessedUpNode2 ref) { | ||
this.ref = ref; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
test/src/test/java/org/neo4j/ogm/domain/gh666/MessedUpNode2.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,53 @@ | ||
/* | ||
* 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.gh666; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.neo4j.ogm.annotation.GeneratedValue; | ||
import org.neo4j.ogm.annotation.Id; | ||
import org.neo4j.ogm.annotation.Labels; | ||
import org.neo4j.ogm.annotation.NodeEntity; | ||
|
||
/** | ||
* @author Michael J. Simons | ||
*/ | ||
@NodeEntity | ||
public class MessedUpNode2 { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
@Labels | ||
private List<String> types = new ArrayList<>(); | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public List<String> getTypes() { | ||
return types; | ||
} | ||
|
||
public void setTypes(List<String> types) { | ||
this.types = types; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/src/test/java/org/neo4j/ogm/domain/gh666/MessedUpNode3.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,49 @@ | ||
/* | ||
* 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.gh666; | ||
|
||
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 MessedUpNode3 { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
private MessedUpNode2 relationA; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public MessedUpNode2 getRef() { | ||
return relationA; | ||
} | ||
|
||
public void setRef(MessedUpNode2 ref) { | ||
this.relationA = ref; | ||
} | ||
} |
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