Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-05-2020 12:57 AM
I am unable to save createdby and updatedby in spring boot neo4j in spring boot 2.3.5. i have annotated them with CreatedDate, CreatedBy, LastModifiedBy, LastModifiedDate and used spring data annotation of prepersist and preupdate but nothing is happening
Solved! Go to Solution.
11-06-2020 12:11 AM
Spring Data Neo4j does not support the JPA annotations for prepersist and preupdate. You would provide the username by implementing the AuditorAware
interface:
class MyUserProvider implements AuditorAware<String> {
public Optional<String> getCurrentAuditor() {
return Optional.of("MyUserName");
}
}
This also helps to separate the logic for auditing and user resolution from your domain model.
See https://docs.spring.io/spring-data/neo4j/docs/5.3.x/reference/html/#auditing.auditor-aware for more information.
11-05-2020 11:42 PM
Did you enable the auditing feature for Spring Data Neo4j?
11-05-2020 11:46 PM
I did enable it @EnableNeo4JAuditing. I am using these annotations to update the createdby and updatedby while with the above auditing annotation it was updating the createdAt and updatedAt but not the by ones.
11-06-2020 12:11 AM
Spring Data Neo4j does not support the JPA annotations for prepersist and preupdate. You would provide the username by implementing the AuditorAware
interface:
class MyUserProvider implements AuditorAware<String> {
public Optional<String> getCurrentAuditor() {
return Optional.of("MyUserName");
}
}
This also helps to separate the logic for auditing and user resolution from your domain model.
See https://docs.spring.io/spring-data/neo4j/docs/5.3.x/reference/html/#auditing.auditor-aware for more information.
All the sessions of the conference are now available online