Introduction
Changelog
Contact
Guides
Getting Started
Entities
Repositories
Queries & Specifications
Configuration & Pooling
Migrations
Spring Boot
Spigot & Paper Plugins
Recipes
Reference
Databases
Troubleshooting
Advanced
Multi-tenancy
Audit Trail
Testing
TrademarkTrademark
Ctrl k
Search…
Get started
Introduction
Changelog
Contact
Guides
Getting Started
Entities
Repositories
Queries & Specifications
Configuration & Pooling
Migrations
Spring Boot
Spigot & Paper Plugins
Recipes
Reference
Databases
Troubleshooting
Advanced
Multi-tenancy
Audit Trail
Testing
TrademarkTrademark© Aveiro. All rights reserved.
Built with Aveiro
Advanced

Audit Trail

Record a full change history with Hibernate Envers: annotate entities, enable audit, and query past revisions.
Updated last month
Multi-tenancy
Testing
JEHibernate integrates Hibernate Envers to record a change history — who changed what, and when — for the entities you opt in. It is off until you both annotate an entity and enable it.

Enable it

Add Envers to the classpath (it is an optional dependency) and call enableAudit():
implementation("org.hibernate.orm:hibernate-envers:7.4.13.Final")
config.enableAudit();

Audit an entity

Mark the entity (or individual fields) with @Audited:
@Entity
@Audited
public class Warp extends LongIdEntity {
    private String name;
    private String world;
}
Envers maintains an audit table per audited entity plus a revision table. JEHibernate's revision entity records the revision number, timestamp, the resolved user and source IP, and the current tenant.

Capturing who made a change

Register an AuditUserResolver once through AuditContext. It is called per revision to attribute the change, so you plug in however your application knows the current actor.
AuditContext.setResolver(() -> currentActorName());   // AuditUserResolver

Querying history

The query API takes the EntityManagerFactory from your JEHibernate instance.
var emf = jeHibernate.getEntityManagerFactory();

List<Number> revisions = Audit.getRevisionNumbers(emf, Warp.class, warpId);
List<Warp>   history    = Audit.getRevisions(emf, Warp.class, warpId);
var info                = Audit.getRevisionInfo(emf, revisionNumber);
Data-protection note
An audit trail stores historical personal data. Define a retention period and an erasure path (DSGVO Art. 5, 17) before enabling it in production — the repository's docs/audit-guide.md covers this.
There is no built-in purge job: retention and erasure are deliberately left to you, so you control exactly what is kept and for how long.