Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-20-2020 12:16 PM
(or maybe I don't know how to make it work)
I have @EnableNeo4jAuditing on the @Configuration class and @LastModifiedDate works just fine!
But how do I get the created date set? It stays null, no matter which data type I use. What am I missing? (Spring Boot 2.4.0, Java 15)
THANKS for any help or hints!
Cheers, Chris
11-23-2020 02:33 AM
I assume that you are using assigned identifiers(?). In this case SDN cannot distinguish between new or existing entity because the identifier controls the isNew
detection.
11-23-2020 03:36 AM
Hi Gerrit,
Here is the simple example I am playing around with:
@Node
public class Movie {
@Id @GeneratedValue private long id;
@Version private Long version;
@CreatedDate private LocalDateTime created;
@LastModifiedDate private LocalDateTime modified;
private String title;
private String tagline;
private Integer released;
...
modified is set correctly on each change, created is never set.
What has to be done to make this work?
In the past I had an OGM EventListenerAdapter that would set created and modified for me but I thought I would give this built in feature a try. Oh BTW is there a doc/example somewhere how to implement something like an "onPreSave" in the new SDN 6?
Cheers,
Chris
11-24-2020 05:17 AM
Any info is appreciated 😉
11-24-2020 05:37 AM
Short answer: Use a Long
instead of the primitive long
as the type for you id
.
Longer answer: Due to the fact that Neo4j now handles also 0
as a valid identifier value, SDN cannot determine if the node is new or not. As a result it returns false
for the new check because the primitive long
is 0
.
11-24-2020 05:44 AM
Oh - LOL! ... and I was playing with different types of the created field
Thanks!
All the sessions of the conference are now available online