A demonstration project showcasing Entity Auditing capabilities using Hibernate Envers in a Helidon MP application.
Entity Auditing is a critical aspect of enterprise applications that need to track changes to data over time. It provides:
- Historical record of all changes made to entities
- Ability to restore previous versions of data
- Audit trails for compliance and security purposes
- Transparency in multi-user systems
This project demonstrates how to implement entity auditing in a Java application using Hibernate Envers.
Hibernate Envers is an auditing module for Hibernate ORM that automatically tracks historical changes to your persistent entities. Key features include:
- Automatic versioning of entity data
- Minimal configuration through annotations
- Seamless integration with existing Hibernate applications
- Support for querying historical data
- Ability to retrieve and restore previous entity versions
Envers works by creating audit tables that mirror your entity tables, storing a copy of the entity's state whenever it changes.
Helidon MP is a lightweight MicroProfile framework for building Java microservices. It provides built-in support for REST APIs, configuration, health checks, and metrics with minimal overhead and fast startup times. Helidon's declarative programming model complements Hibernate Envers well, allowing for clean implementation of audit functionality in microservices.
- Helidon MP 4.2.0
- JDK 21 or higher
- Maven 3.8+
- Docker (optional, for containerized deployment)
- Kubernetes (optional, for container orchestration)
With JDK21:
mvn package
java -jar target/hero-coders-backend.jar
The project includes a sample.http
file that contains sample REST calls to demonstrate the functionality of the API.
The sample.http
file provides example REST calls to demonstrate the API's functionality. The recommended way to use this file is with the REST Client VS Code extension. This extension allows you to send HTTP requests and view responses directly within VS Code.
The sample requests demonstrate:
- Creating a new hero
- Retrieving all heroes
- Getting the audit history of a specific hero
- Restoring a hero to a previous version
The sample requests demonstrate:
- Creating a new hero
- Retrieving all heroes
- Getting the audit history of a specific hero
- Restoring a hero to a previous version
To build a Docker image for the application, run the following command:
docker build -t hero-coders-backend .
To run the Docker container, use:
docker run -p 8080:8080 hero-coders-backend