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

**URL:** <https://community.neo4j.com/t/spring-data-neo4j-creating-a-node-with-a-relationship-to-an-existing-node/7816>\
**Category:** Spring Data Neo4j & Neo4j-OGM\
**Created:** [June 3, 2019, 1:43pm UTC](https://community.neo4j.com/t/spring-data-neo4j-creating-a-node-with-a-relationship-to-an-existing-node/7816 "2019-06-03T13:43:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.vandriessche](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/thomas.vandriessche/32/5082_2.png) [@thomas.vandriessche](https://community.neo4j.com/u/thomas.vandriessche)\
**Post date:** [June 3, 2019, 1:43pm UTC](https://community.neo4j.com/t/spring-data-neo4j-creating-a-node-with-a-relationship-to-an-existing-node/7816/1 "2019-06-03T13:43:49Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![gerrit.meier](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gerrit.meier/32/27374_2.png) [@gerrit.meier](https://community.neo4j.com/u/gerrit.meier)\
**Post date:** [June 6, 2019, 8:25am UTC](https://community.neo4j.com/t/spring-data-neo4j-creating-a-node-with-a-relationship-to-an-existing-node/7816/2 "2019-06-06T08:25:00Z")

</div>

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`.
