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():
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.
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.