Spring Data Neo4j - Auditing @CreatedDate

Hi,
I'm trying to use spring-data-neo4j 5.2.4.RELEASE, and in particular the Auditing @createdDate functionality

@NodeEntity
public class Person {
  
   @Id
   private Long idSubject;

   @CreatedDate
   private long dtInsert;
  
   @LastModifiedDate
   private long dtUpdate;
...

@CreatedDate seems not to work. When the object is created the first time in the db with repository.save (obj) only dtUpdate is set.

Is it a bug or has someone managed to make it work?

Thank you!
Antonio Bruno

You are not using a generated id but set it by yourself. This is a known limitation in SDN because we cannot differentiate if the entity is new or just gets updated.
We documented this in the Spring Data Neo4j reference.

1 Like

Ok thanks, I missed the note :sweat_smile:

@gerrit_meier so there is no mechanism in SDN-OGM to do in a single operation what the native cypher query does with syntax

MERGE ...
ON CREATE SET ...
ON MATCH SET ...

If I use SDN-OGM in this case, am I obliged to make a findById(obj.idSubject) first and then a save(obj)?

Sincerely
Antonio Bruno