liveBook · Manning

Auditability

As explained in Java Persistence with Spring Data and Hibernate epub

An audit log, or audit trail, is a chronological record of data changes that supports historical review and accountability.

Auditability preserves a chronological record of data changes for historical review and accountability. An audit trail can record the affected entity, event type, user, and timestamp, either in a dedicated table or in versioned historical tables. section 13.2.2 section 13.3

Hibernate applications can implement auditability through two main strategies:

  • A custom interceptor marks auditable entities, collects inserts and updates, and persists AuditLogRecord instances after flushing. section 13.2.2
  • Hibernate Envers listens to Hibernate events, stores entity copies in audit tables, and groups modifications in transactions under revision numbers. section 13.3 section 13.3.1
  • Database triggers provide another option, while application-level auditing can better preserve portability across database systems. section 13.2.2

Versioned Item history

Enable @Audited on Item and User, optionally exclude bids with @NotAudited, then create an item, modify its name and seller, and delete it in separate transactions. Envers records revisions in ITEM_AUD, USERS_AUD, and REVINFO, retaining earlier versions after deletion. section 13.3.1 section 13.3.2

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Explains entity marking, metadata, interceptors, event handling, revision tables, and historical queries.
Examples
Demonstrates audited Item and User entities, excluded bids, revision tables, and create-modify-delete transaction sequences.
What it assumes
Assumes familiarity with EntityManager transactions and persistent entities while introducing audit-specific mappings and lifecycle handling.
What you can do after
Apply Envers annotations or configure a Hibernate interceptor to retain and retrieve entity-change history.
How it connects
Connects database triggers, Hibernate interceptors, event listeners, transactions, revisioning, and historical queries.

Also explained in

Compare how 6 books explain auditability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.