img
Table 10-6. Properties for Hibernate Envers
Column Type
Description
The table name suffix for the versioned entity. For example, for
audit_table_suffix
the entity class ContactAudit, which is mapped to the
CONTACT_AUDIT table, Envers will keep the history in the table
CONTACT_AUDIT_H, since we defined the value _H for the property.
The history table's column for storing the revision number for
revision_field_name
each history record.
The history table's column for storing the update action type.
revision_type_field_name
The audit strategy to use for entity versioning.
audit_strategy
The history table's column for storing the end revision number
audit_strategy_validity_end_
for each history record. Required only when using the validity
rev_field_name
audit strategy.
Whether to store the timestamp when the end revision number
audit_strategy_validity_store_
for each history record is updated. Required only when using
revend_timestamp
the validity audit strategy.
The history table's column for storing the timestamp when the
audit_strategy_validity_revend_
end revision number for each history record is updated.
timestamp_field_name
Required only when using the validity audit strategy and the
previous property is set to true.
Coding Changes for Entity Versioning and History Retrieval
To enable the versioning of an entity, just annotate the entity class with @Audited. Listing 10-49 shows
the ContactAudit entity class with the annotation applied.
Listing 10-49. The Revised ContactAudit Class
package com.apress.prospring3.ch10.domain;
// Import statements omitted
import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;
@Entity
@Audited
@Table(name = "contact_audit")
public class ContactAudit implements Auditable<String, Long>, Serializable {
// Other code omitted
@ManyToMany
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home