Reputation: 588
I have two connected entities
(ProductInstance)-[:INSTANCE_OF]->(Product)
I am now attempting to create a ChangeroomSession
, which has a relationship to several ProductInstances
:
public class ChangeroomSession {
//other fields
@Relationship(type = "INCLUDES", direction = Relationship.Direction.OUTGOING)
private List<ProductInstance> productInstances;
}
Doing so results in the unexpected deletion of already-persisted relationships between ProductInstances
and Products
in my graph. For example, assume I have two ProductInstance
s p1,p2
(light blue) connected to a single Product (dark blue).
Next, I create a new ChangeroomSession
and set its product instance list to contain both p1
and p2
. After performing this operation, the ChangeroomSession
persists with relationships to p1
and p2
successfully, but the relationship between one of the ProductInstance
s and the Product
is unexpectedly deleted.
Here is the code:
List<ProductInstance> productInstances = findProductInstancesByIdIn(...)
ChangeroomSession changeroomSession = new ChangeroomSession(productInstances);
this.changeroomSessionRepository.save(changeroomSession);
What is even more interesting is that if I set a breakpoint in the code execution, the changeroomSession
object I am about to persist shows the missing relationship as being present. More than that, the returned object from the .save
operation also shows it. It is only after the persist operation if I query the database again that the relationship is gone
This feels like unexpected behaviour - am I missing something? Why is this happening? Thanks!
Upvotes: 1
Views: 151