@Table(name = "PETCLINIC_OWNER")
@Entity(name = "petclinic_Owner")
@Audited // all fields of the entity will be audited
public class Owner extends Person {
...
}
@Entity(name = "petclinic_Pet")
// only some fields will be audited
public class Pet extends NamedEntity {
private static final long serialVersionUID = -3431453457784831240L;
@NotNull
@Column(name = "IDENTIFICATION_NUMBER", nullable = false)
@Audited
protected String identificationNumber;
@Temporal(TemporalType.DATE)
@Column(name = "BIRTH_DATE")
@Audited
protected Date birthDate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID")
protected PetType type;
...
}
Take https://hibernate.org/orm/envers/ as a canonical way.