Search in sources :

Example 1 with SubclassPropertyMapper

use of org.hibernate.envers.internal.entities.mapper.SubclassPropertyMapper in project hibernate-orm by hibernate.

the class AuditMetadataGenerator method generateInheritanceMappingData.

private Triple<Element, ExtendedPropertyMapper, String> generateInheritanceMappingData(PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData, String inheritanceMappingType) {
    final String extendsEntityName = verEntCfg.getAuditEntityName(pc.getSuperclass().getEntityName());
    final Element classMapping = MetadataTools.createSubclassEntity(xmlMappingData.getMainXmlMapping(), inheritanceMappingType, auditTableData, extendsEntityName, pc.getDiscriminatorValue(), pc.isAbstract());
    // The id and revision type is already mapped in the parent
    // Getting the property mapper of the parent - when mapping properties, they need to be included
    final String parentEntityName = pc.getSuperclass().getEntityName();
    final EntityConfiguration parentConfiguration = entitiesConfigurations.get(parentEntityName);
    if (parentConfiguration == null) {
        throw new MappingException("Entity '" + pc.getEntityName() + "' is audited, but its superclass: '" + parentEntityName + "' is not.");
    }
    final ExtendedPropertyMapper parentPropertyMapper = parentConfiguration.getPropertyMapper();
    final ExtendedPropertyMapper propertyMapper = new SubclassPropertyMapper(new MultiPropertyMapper(), parentPropertyMapper);
    return Triple.make(classMapping, propertyMapper, parentEntityName);
}
Also used : Element(org.dom4j.Element) EntityConfiguration(org.hibernate.envers.internal.entities.EntityConfiguration) SubclassPropertyMapper(org.hibernate.envers.internal.entities.mapper.SubclassPropertyMapper) MultiPropertyMapper(org.hibernate.envers.internal.entities.mapper.MultiPropertyMapper) ExtendedPropertyMapper(org.hibernate.envers.internal.entities.mapper.ExtendedPropertyMapper) MappingException(org.hibernate.MappingException)

Aggregations

Element (org.dom4j.Element)1 MappingException (org.hibernate.MappingException)1 EntityConfiguration (org.hibernate.envers.internal.entities.EntityConfiguration)1 ExtendedPropertyMapper (org.hibernate.envers.internal.entities.mapper.ExtendedPropertyMapper)1 MultiPropertyMapper (org.hibernate.envers.internal.entities.mapper.MultiPropertyMapper)1 SubclassPropertyMapper (org.hibernate.envers.internal.entities.mapper.SubclassPropertyMapper)1