cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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: https://stackoverflow.com/questions/36375560/spring-data-neo4j-create-new-node-with-a-relationship-w...

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

1 REPLY 1

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.