Home

HibernateEnvers

Hibernate Envers is a module of the Hibernate ORM project that provides auditing and versioning for persistent entities. It automatically records historical states of entities by maintaining audit tables and revision information. By annotating an entity with @Audited, Envers tracks changes to that entity; fields can be excluded with @NotAudited. Relationships can also be audited with @AuditMappedBy.

Under the hood, Envers uses a revision entity (default DefaultRevisionEntity) that stores a revision number and

Usage involves enabling Envers in the configuration by including the hibernate-envers module and enabling auditing via

Customization allows you to supply your own revision entity with @RevisionEntity to store extra information. Auditing

Limitations include performance overhead and schema complexity. Not all field types are auditable by default, and

Hibernate Envers is commonly used for regulatory compliance, data recovery, and historical data analysis, and integrates

timestamp.
Each
change
to
an
audited
entity
is
logged
in
a
corresponding
audit
table,
typically
named
Entity_AUD,
with
columns
for
all
fields
plus
REV
and
REVTYPE
to
indicate
insert,
update,
or
delete.
A
separate
revision
table
stores
metadata
about
each
revision.
annotations.
The
API
provides
AuditReader
and
AuditQuery
for
retrieving
historical
data,
such
as
the
state
of
an
entity
at
a
given
revision
or
all
revisions
within
a
range.
of
relationships
can
be
configured
with
@AuditMappedBy
and
related
mapping
attributes.
auditing
large
collections
requires
careful
design.
with
JPA
and
Hibernate's
event
system
to
provide
a
transparent
audit
trail.