javaspringjpaspring-dataspring-data-jpa

How does @CreatedBy work in Spring Data JPA?


I used @CreatedDate on entity property and I see that it inserts date into db. I don't understand what is the purpose of @CreatedBy annotation in Spring Data JPA.

In the reference documentation I read :

We provide @CreatedBy, @LastModifiedBy to capture the user who created or modified the entity

But how to create and use such user?


Solution

  • If you already made it to the reference documentation, I recommend to read two more paragraphs to find out about and how to use AuditorAware. :)