Enabling Entity Versioning and History Retrieval
To enable versioning of an entity, just annotate the entity class with @Audited. Listing 8-49 shows the ContactAudit entity class with the annotation applied.
Listing 8-49. The ContactAudit Class
package com.apress.prospring4.ch8;import static javax.persistence.GenerationType.IDENTITY;import java.io.Serializable;import java.util.Date;import javax.persistence.Entity;import javax.persistence.Table;import javax.persistence.Id;import javax.persistence.GeneratedValue;import javax.persistence.Column;import javax.persistence.Version;import javax.persistence.Temporal;import javax.persistence.TemporalType;import javax.persistence.Transient;import org.hibernate.annotations.Type;import org.springframework.data.domain.Auditable; ...
Get Pro Spring,Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.