From a pure annotation-perspective, this would effectively need to be mapped as follows:
@OneToMany(mappedBy = "myEntity", targetEntity=MyAbstractOtherEntity.class)
@AuditMappedBy(mappedBy = "myEntity")
private List<MyOtherEntity> myOtherEntities;
The key point here is to notice the targetEntity attribute on the @OneToMany annotation. Unfortunately, HBM does not have an equivalent mapping model here and therefore in order to have this work, your XML mapping should actually be:
<bag name="myOtherEntities" inverse="true" lazy="true" fetch="subselect" cascade="all-delete-orphan">
<key column="MyEntity" foreign-key="none"/>
<one-to-many class="org.hibernate.envers.test.integration.mapping.MyAbstractOtherEntity"/>
</bag>
By pointing to the abstract class in the XML, the property mapping and mapped by logic works fine both in ORM and Envers. |