Data Auditing in Spring Data JPA

Many systems require auditing and tracking the change in the persistence layer. It is really helpful to investigate problems related to the data. Data auditing typically answers these questions: when was it created, who was create the record, when was it created, who modified the record last and when was it modified last. Spring provides four annotations in the spring-data-commons module for auditing features. @CreatedByrepresents the principal that created the entity containing the field. @CreatedDate represents the date the entity containing the field was created. @LastModifiedBy represents the principal that recently modified the entity containing the field. @LastModifiedDaterepresents the date the entity containing the field was recently modified. Besides the four mentioned annotations, Spring also provides @EnableJpaAuditing that aims enable auditing feature. In order to explain how the auditing feature works in Spring Data JPA, we should be known abou...