In this example you can see how to use Envers for Auditing your tables.
- Java
17.x
e.g.:sdk install java 17.0.9-amznsdk install java 17.0.9-amzn
- Gradle
8.x
e.g. you can use the embedded wrappergradlew
or installsdk install gradle 8.5
- Docker
26.x
- MySQL
8.2.x
. Check the Docker section - Postman (or any rest client)
This is based on Spring Boot Application 3.2.1
, and it is configured with mysql database.
There are the following entities:
- AuditEnversInfo --> auditory master table
- Person --> this entity can be a customer or employee.
- Order
- Product
- OrderDetail
For each table (entity) the framework will create the auditory tables.
docker run --name mysql-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=jcalvopinam -d mysql:8.2.0
docker start mysql-db
docker stop mysql-db
-
Since the current version, it is not necessary create manually the schema, when the application startup, it will create the schema and the entities. Anyway you can find the script in
src/main/resources/db/scripts/database.sql
as well as the script with the DDL of tablestables.sql
-
Compile the project with the following command:
./gradlew clean build
- You can run the application inside your ide from
src/main/java/com/jcalvopinam/SampleEnversApplication.java
or from terminal with the following command:
./gradlew bootRun
I used the postman application as a client to test the endpoints, you can import the collection:
ll src/main/resources/endpoints/collection\[postmanv2.1\].json
Or if you prefer, you can look at the Controllers inside of com.jcalvopinam.web
package and the DTOs inside of com.jcalvopinam.dto