Spring Data MongoDB Auditing
Transparently keep track of who created or changed an entity and when the change happened
Spring Data provides support to transparently keep track of who created or changed an entity and when the change happened. The auditing facility allows administrators and users to track system activity with multiple users and applications. To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface.
Annotation-based Auditing Metadata
Spring Data provides several annotations for auditing:
@CreatedBy
and@LastModifiedBy
to capture the user who created or modified the entity.@CreatedDate
and@LastModifiedDate
to capture when the change happened.
Auditing metadata does not necessarily need to be in the entity class but can be added to a base class which would be extended by all audited entities like in the snippet bellow: