# Spring Data Neo4j does not update node

**URL:** <https://community.neo4j.com/t/spring-data-neo4j-does-not-update-node/37928>\
**Category:** Spring Data Neo4j & Neo4j-OGM\
**Created:** [May 6, 2021, 6:34pm UTC](https://community.neo4j.com/t/spring-data-neo4j-does-not-update-node/37928 "2021-05-06T18:34:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaltePetersen](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/maltepetersen/32/18157_2.png) [@MaltePetersen](https://community.neo4j.com/u/MaltePetersen)\
**Post date:** [May 6, 2021, 6:34pm UTC](https://community.neo4j.com/t/spring-data-neo4j-does-not-update-node/37928/1 "2021-05-06T18:34:59Z")

</div>

I user spring-boot-starter-data-neo4j version 2.4.5

I think it has something to do with the following warning:  
Instances of class de.fh.kiel.advancedjava.pojomodel.model.Pojo with an assigned id will always be treated as new without version property!  
which always pops up if I try to save anything.

My node:

```auto

@Node
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Pojo {

    private boolean emptyHull;

    @Id
    private String completePath;
    private String className;
    private Package aPackage;

    @Relationship(type = "attributes")
    private Set<Attribute> attributes;

    @Relationship(type = "parent")
    private Pojo parentClass;

    @Relationship(type = "interfaces")
    private Set<String> interfaces;
}

```

If try to update the node like this:

```auto
var pojo = pojoRepository.findById(id);
changeAttributesOfPojo(pojo);

pojoRepository.save(pojo)

```

it does not update the node.

My ids look like this: de.fh.kiel.advancedjava.pojomodel.exampleData.DefaultClass  
They are names names but each name is unique.

I tried to add a version property like this:

```auto
   @Version
    private Long version;

```

My Application did not work after that. I guess I need to add it differently or need to change my constructurs for that to work. But is the verison property even the problem?

---

<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:** [May 6, 2021, 8:25pm UTC](https://community.neo4j.com/t/spring-data-neo4j-does-not-update-node/37928/2 "2021-05-06T20:25:54Z")

</div>

Yes, that is right. Because the entity is seen as new, no relationship will be dropped.  
But it should create new ones.

> [@MaltePetersen](#):
>
> My Application did not work after that.

I assume that the problem is the missing `version` property on the `Pojo` nodes now. It has to be set before working with the data because otherwise there would be no chance for SDN to enable the versioning / optimistic locking.  
Basically a `MATCH (n:Pojo) SET n.version = 0` would be enough to get it running.
