Home

AuditReader

AuditReader is a component of Hibernate Envers that provides read-only access to the historical state of persisted entities. It enables applications to reconstruct past entity states and analyze how data has changed over time by querying audit data that Envers maintains for audited entities.

To use AuditReader, you obtain it from the current JPA or Hibernate session via AuditReaderFactory.get(entityManager). Audit

Key capabilities include retrieving an entity as it existed at a specific revision, listing all revisions for

Configuration and usage considerations: Envers requires enabling auditing and annotating relevant entities with @Audited. Audit tables

data
is
stored
in
separate
audit
tables
(commonly
named
with
an
_AUD
suffix)
and
is
tied
to
revisions
recorded
in
the
REVINFO
table.
AuditReader
itself
does
not
write
data;
it
only
reads
and
interprets
existing
audit
records.
a
given
entity,
and
obtaining
the
timestamp
of
a
particular
revision.
Common
methods
are
find(entityClass,
id,
revision),
getRevisions(entityClass,
id),
and
getRevisionDate(revision).
AuditReader
also
supports
building
advanced
queries
through
createQuery(),
which
can
target
entities
at
a
given
revision,
entities
changed
in
a
revision,
or
entities
at
a
particular
property
state.
Queries
can
also
expose
the
RevisionType
to
indicate
added,
modified,
or
deleted
changes.
and
revision
information
are
created
automatically
unless
customized.
While
AuditReader
provides
powerful
read
access
to
historical
data,
auditing
introduces
additional
storage
requirements
and
potential
performance
considerations
for
write
operations,
and
complexity
can
increase
when
auditing
associations
and
complex
relationships.