You need to add auditing features to track changes in entity data. What Hibernate feature would you use to achieve this?

Hibernate Envers is the standard Hibernate module for auditing entity changes. It automatically tracks every insert, update, and delete made to annotated entities and stores each change as a numbered revision in a separate history table.

Key Points: • Annotate an entity (or specific fields) with @Audited to enable revision tracking for it. • Envers creates a shadow "_AUDIT" table per audited entity plus a REVINFO table storing revision number, timestamp, and optionally the author. • You can query historical state using AuditReader to fetch an entity as it existed at a given revision. • Works transparently with the persistence context — no manual logging code is required in business logic. • Supports auditing associations, so you can see how relationships between entities changed over time.

Example: On a Order entity annotated with @Audited, every time a price or status field is updated and the transaction commits, Envers writes a new row to order_AUDIT capturing the field values and the revision that produced them, so you can later answer "what did this order look like last Tuesday."

Interview Tip: A concise interview answer is:

"For entity auditing I'd use Hibernate Envers — annotating entities with @Audited makes Hibernate automatically persist every revision to a shadow audit table, so I get full change history without writing manual logging code, and I can query past states through the AuditReader API."