Spring data mongodb auditing not working.. (Java config)
The actual problem was the @Id
annotation. To use spring auditing properly, you have to define an ObjectId (null for new saved objects), thats how spring decide @LastModifiedDate
and @CreatedDate
Afterwards, i found a way to make it possible use custom beans on @Id
by implementing Auditable<String,String>
Thanks to @Felby:
I found that the @Id field needed to be null at the time of save() only for the @CreatedDate and @CreatedBy annotations. The @LastModifiedDate and @LastModifiedBy fields worked regardless of whether the @Id field was initialized or not.
I don't know exactly, but try to add joda-time to classpath to use date-related audit annotations
<dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.2</version></dependency>