cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site maintenance this Wednesday, February 1. Disruptions expected as we migrate the forums.

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

2 REPLIES 2

gerrit_meier
Neo4j
Neo4j

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.

Ok thanks, I missed the note

@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