| By taking the following simple example, Envers will only add the MOD fields for the _contactInfo and name properties of the Person entity. It would be useful to be able to not only track that the embeddable object changed, but precisely what fields within the embeddable changed as well.
@Entity
@Audited(withModifiedFlag = true)
public class Person {
@Id
@GeneratedValue
private Integer id;
private String name;
@Embedded
private ContactInfo contactInfo;
/** getter / setters */
}
@Embeddable
public class ContactInfo {
private String emailAddress;
private String phoneNumber;
/** getter / setters */
}
It's worth noting that when using the query API as follows that it will result in an error org.hibernate.QueryException: could not resolve property: contactInfo.
getAuditReader().createQuery().forRevisionsOfEntity( Person.class , false, true )
.add( AuditEntity.id().eq( personId ) )
.add( AuditEntity.property( "contactInfo.emailAddress" ).hasChanged() )
.getResultList();
|