Inherited properties are not audited when only the leaf class is marked for auditing in EAP 6
Issue
Properties inherited from a MappedSuperclass are not audited (and are null in the revision data for an Audited subclass)
@MappedSuperclass
public abstract class BaseClass {
@Id
private long id;
private String baseProperty;
...
public String getBaseProperty() {
return baseProperty;
}
public void setBaseProperty(String baseProperty) {
this.baseProperty = baseProperty;
}
...
}
@Entity
@Audited
public class LeafClass extends BaseClass {
private String leafProperty;
...
public String getLeafProperty() {
return leafProperty;
}
public void setLeafProperty(String leafProperty) {
this.leafProperty = leafProperty;
}
...
}
public void test() {
// create LeafClass instance
...
transaction.begin();
{
LeafClass lc = entityManager.createQuery("from LeafClass l", LeafClass.class).getSingleResult();
AuditReader reader = AuditReaderFactory.get(entityManager);
List<Number> revs = reader.getRevisions(LeafClass.class, lc.getId());
LeafClass lcRev1 = reader.find(LeafClass.class, lc.getId(), revs.get(0));
assertEquals("Leaf property match", lc.getLeafProperty(), lcRev1.getLeafProperty());
assertEquals("Base property match", lc.getBaseProperty(), lcRev1.getBaseProperty()); // fails lcRev1.baseProperty == null
}
transaction.commit();
}
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6
- Hibernate/Envers 4
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.