此内容没有您所选择的语言版本。
1.5.4. Getting Started with Entity Auditing
1.5.4.1. Add Auditing Support to a JPA Entity 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
- Task Summary
- This topic covers adding auditing support for a JPA entity.
Procedure 1.1. Add Auditing Support to a JPA Entity
- Configure the available auditing parameters to suit the deployment (refer to Section 1.5.5.1, “Configure Envers Parameters”)
- Open the JPA entity to be audited.
- Import the
org.hibernate.envers.Auditedinterface. - Apply the
@Auditedannotation to each field or property to be audited, or apply it once to the whole class.Example 1.1. Audit Two Fields
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example 1.2. Audit an entire Class
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Result
- The JPA entity has been configured for auditing. A table called
Entity_AUDwill be created to store the historical changes.