Spring data neo4j creating a node with a relationship to an existing node

Hi all,

We just started to work with spring data neo4j.
But have run into the problem when creating a node with a relationship to another existing node.
For example: Spring Data Neo4J - Create new node with a relationship with an existing node - Stack Overflow

Is it true that we have to write a custom query or fetch the existing node first before being able to create a relationship to that existing node without overriding the current properties?

kind regards

You don't need necessarily to write a custom cypher statement to load the (existing) node but it has to be somehow known (e.g. findById) in the transaction.
If you would create two nodes A and B, where B is the already existing one, Spring Data Neo4j / Neo4j-OGM cannot foresee that B will already be in the graph when you persist A.

1 Like