# How to delete an edge(relationship) by Spring Data Neo4j 7.0

**URL:** <https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413>\
**Category:** Spring Data Neo4j & Neo4j-OGM\
**Tags:** ogm, migrated\
**Created:** [January 18, 2023, 2:52pm UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413 "2023-01-18T14:52:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://community.neo4j.com/u/LazyCat)\
**Post date:** [January 18, 2023, 2:52pm UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/1 "2023-01-18T14:52:03Z")

</div>

```
     I am a student majored in AI, learning Neo4j and Spring Data Neo4j 7.0 edition( in short, SDN). Now I am making a tutorial project with Neo4j official Movie dataset for Spring Data Neo4j, address is here:

```

[https://github.com/Eternal-night-blip/Spring-Data-Neo4j-Tutorial/tree/fail-delete-relation](https://github.com/Eternal-night-blip/Spring-Data-Neo4j-Tutorial/tree/fail-delete-relation).

```
    Some problem are encountered. I am new to Spring Data,never use OGM before. I am so confused, when deleting an edge fails by SDN. I don't know the reason,could do help me and fix the bug.

   The Person Entity is below

   ![person.png](https://community.neo4j.com/t5/image/serverpage/image-id/7920i2F91466203553B82/image-size/large/is-moderation-mode/true?v=v2&px=999 "person.png")

     I define the deleteActedIn method in Person class

```

![deleteActedInMethod.png](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/9/f/9ffc62c4e89ea234c2946ad24e72298305133934.png "deleteActedInMethod.png")

```
      you can use command line interface to interact the project( I use Spring Shell to assist me)

      when you start the project, you can input "help" to get all commands.

      firstly, you input "add-person p1 1990 " to create a Person node, then input "add-movie movie1 movietagline 2017" to creat a Movie node, input "acted-in p1 movi1 role1" to create an ACTED\_IN relationoship between p1 and movie1.

      Lastly you can input "delete-acted-in p1 movi1" to delete the relationship, it seems success, but you input "check p1 movi1" or inspect Neo4j Databae, you can find that the relationship doesn't be removed.

```

 ![deleteActedInCommand.png](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/2/e/2ed626616b5b747144394646c24393d146875a1f.png "deleteActedInCommand.png")

```
   I guess that there is a possible error that the method save of PersonRepository (extends Neo4jRepostory) can't save Person object after executing the operation of deleting relationship. However, It can save Person object after adding a relationship. That makes me puzzled.

    Thank you for helping me.

```

---

<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:** [January 19, 2023, 4:15pm UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/2 "2023-01-19T16:15:44Z")

</div>

You are using provided ids here. If you update the entities, it will always be considered as a new entity, because SDN cannot be sure if it already exists in the database in contrast to entities defined with \_GeneratedValue\_ at the id property.

You could also see the warning:  
WARN 57763 --- [main] o.s.d.n.c.m.DefaultNeo4jIsNewStrategy : Instances of class com.ilvo.neo4jdemo.nodes.Person with an assigned id will always be treated as new without version property

To solve this, the Person needs to get an additional field:  
@Version  
Long id;

---

<div class="post-metadata">

**Author:** ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://community.neo4j.com/u/LazyCat)\
**Post date:** [January 20, 2023, 3:52pm UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/3 "2023-01-20T15:52:04Z")

</div>

So,does SDN 7.0 has a map to elementId now ?

---

<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:** [January 20, 2023, 7:39am UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/4 "2023-01-20T07:39:44Z")

</div>

Nothing you have to worry about.In general we advise to not use internal ids on entities. As I can see this is related to relationships in your case. Basically nothing you or we could do right now.  
A little bit of background: Neo4j shifted with version 5 to something parallel to the legacy ids called elementId. We wanted to prepare SDN 7+ for this because ids \_might\_ not work in future major versions of Neo4j. That's why you see this warning.

---

<div class="post-metadata">

**Author:** ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://community.neo4j.com/u/LazyCat)\
**Post date:** [January 20, 2023, 3:42am UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/5 "2023-01-20T03:42:23Z")

</div>

Thank you very much.

I have another question,although having consulted the official reference.

how to fix the warning:

WARN 117602 --- [main] o.s.d.n.c.mapping.Neo4jPersistentEntity : The entity com.ilvo.neo4jdemo.relationships.ActedIn is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.

Must I set another id(or other name, such as myId) to be the external ID which is a property,not a generated identity or elementId in neo4j database ?

---

<div class="post-metadata">

**Author:** ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://community.neo4j.com/u/LazyCat)\
**Post date:** [January 21, 2023, 5:34am UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/6 "2023-01-21T05:34:39Z")

</div>

I have a quick look at the source code of neo4j-java-driver and SDN 7.0 then find that SDN 7.0 doesn't support elementId yet. So when SND supports elementId ?

---

<div class="post-metadata">

**Author:** ![LazyCat](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@LazyCat](https://community.neo4j.com/u/LazyCat)\
**Post date:** [January 23, 2023, 11:11am UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/7 "2023-01-23T11:11:35Z")

</div>

I see, thank you ! ! !

---

<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:** [January 23, 2023, 8:07am UTC](https://community.neo4j.com/t/how-to-delete-an-edge-relationship-by-spring-data-neo4j-7-0/58413/8 "2023-01-23T08:07:30Z")

</div>

No, SDN still sticks with the internal ids (id(node/relationship)) right now and this still works as before.
