简体   繁体   中英

Spring Auditing - How does spring insert @CreatedDate and @LastModifiedDate into database automaticaly?

I am trying to figure out how Spring inserts the createdDate and lastModifiedDate automatically when auditing is configured. I have looked over the reference docs for Spring Data JPA but they only explain how to configure auditing. So how does this work behind the scenes?

I am asking this so I could insert extra auditing data like IP-Address of the user the same way.

Spring data commons has class AuditingHandler , which is responsible for populating createdDate and lasModifiedDate .

You should go-ahead check this link for class definiton and check below methods:

  1. setDateTimeForNow
  2. setModifyOnCreation
  3. touchDate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM