JDBC Auditing
Explore the auditing feature of Spring Data JDBC.
JDBC auditing is a feature in which changes to data stored in a database are automatically tracked and recorded. It helps maintain an audit trail by capturing details such as who made the change and when it occurred, providing a historical record of data modifications by using properties like createdBy
, (the user/system that adds the data), createdAt
(the date and time when the data is added), updatedBy
(the user/system that updates the data), and updatedAt
(the date and time when the data is updated).
Spring Data JDBC provides a sophisticated way of adding auditing features to the Spring Boot project. Let’s explore it.
Database schema setup
First, let’s modify our database schema in the schema.sql
file to add metadata columns that track changes made to the data. So, we add columns like created_by
, created_at
, ...