diff --git a/etc/adr/general-discussion.adoc b/etc/adr/general-discussion.adoc index d6e172b97..de11b12d9 100644 --- a/etc/adr/general-discussion.adoc +++ b/etc/adr/general-discussion.adoc @@ -67,14 +67,13 @@ Supporting the embedded use case will be solved on the drivers level. We provide `@Relationship` for mapping relationships without properties. This annotation shall be used for 1:1 and 1:n mappings. It provides an attribute to specifiy the name of the relationship. -When a relationship is mapped on both sides (that is a circular mapping in the domain model from start to endnode and back) the annotation provides the `inverse` attribute to cater the following use case: [source,java] ---- @Node("User") static class UserNode { - @Relationship(type = "OWNS", inverse = "owner") + @Relationship(type = "OWNS") List bikes; } @@ -86,15 +85,6 @@ static class BikeNode { } ---- -Without the inverse that mapping would lead to three relationships: - -1. `(user) - [:OWNS] -> (bike)` -2. `(user) <- [:OWNER] - (bike)` -3. `(user) <- [:RENTER] - (bike)` - -Which is probably not the intended graph. -Specifying `inverse` removes ambiguity here. - === "Rich" relationships There should be no means of using a relationship as aggregate root in SDN/RX (like it is today the case with `@RelationshipEntity`). diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java b/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java index 6753c1927..c3d474297 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java +++ b/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java @@ -70,11 +70,6 @@ public @interface Relationship { @AliasFor("value") String type() default ""; - /** - * @return The name of the attribute containing the other end of the relationship. - */ - String inverse() default ""; - /** * If {@code direction} is {@link Direction#OUTGOING}, than the attribute annotated with {@link Relationship} will be * the target node of the relationship and the class containing the annotated attribute will be the start node. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java index c8517d377..1b7fb9449 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java +++ b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java @@ -231,7 +231,7 @@ class Neo4jMappingContextTest { @org.springframework.data.annotation.Id @GeneratedValue private long id; - @Relationship(type = "OWNS", inverse = "owner") + @Relationship(type = "OWNS") List bikes; String name; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java index f431436f7..2581ff768 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java +++ b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java @@ -35,7 +35,7 @@ public class SimilarThing { private String name; - @Relationship(type = "SimilarTo", inverse = "similarOf") + @Relationship(type = "SimilarTo") private SimilarThing similar; @Relationship(type = "SimilarTo", direction = Relationship.Direction.INCOMING)