-
Notifications
You must be signed in to change notification settings - Fork 617
Description
Regarding issue
that was about the need of adding relationship-objects to both the Sets of objects in order to save a relationship,
🔵with the dependencies:
spring-boot-starter-data-neo4j:2.6.4
spring-data-neo4j:6.2.2
🔵with the models:
public class Device {
@Id
private Long id;
private String name;
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
@Relationship(type = "BELONGS_TO", direction = Relationship.Direction.OUTGOING)
private Set<Group> groups = new LinkedHashSet<>();
}
public class Group {
@Id
@GeneratedValue(generatorClass = UUIDStringGenerator.class)
private String id;
private String name;
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
@Relationship(type = "BELONGS_TO", direction = Relationship.Direction.INCOMING)
private Set<Device> devices = new LinkedHashSet<>();
}
🔵with the controller for Group (empty because rest services are auto-generated):
@BasePathAwareController
public class GroupController {}
the following POST request on the GroupController ReST endpoint returns a 200 OK (I expect the relationship with devices has been created):
{
"name": "test",
"description" : "",
"devices": ["/1"]
}
but no relationship is created (not treated as a relationship for SDN as you'd have to tell your body that even the Device entity is linking to this very Group object); unfortunately, due to the double-side relationship saving mechanism, Spring Data Rest automatically generated ReST services (HATEOAS) have the relationship creation feature broken:
Do you have a solution for that?
Thanks!