Remove unused inverse field on @Relationship.
The property were never used by the framework and might be misleading. Although this is a breaking API change, we do not want to confuse developers with a misleading property. closes #255
This commit is contained in:
@@ -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<BikeNode> 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`).
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -231,7 +231,7 @@ class Neo4jMappingContextTest {
|
||||
@org.springframework.data.annotation.Id @GeneratedValue
|
||||
private long id;
|
||||
|
||||
@Relationship(type = "OWNS", inverse = "owner")
|
||||
@Relationship(type = "OWNS")
|
||||
List<BikeNode> bikes;
|
||||
|
||||
String name;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user