use of org.hibernate.envers.internal.entities.mapper.CompositeMapperBuilder in project hibernate-orm by hibernate.
the class ComponentMetadataGenerator method addComponent.
@SuppressWarnings({ "unchecked" })
public void addComponent(Element parent, PropertyAuditingData propertyAuditingData, Value value, CompositeMapperBuilder mapper, String entityName, EntityXmlMappingData xmlMappingData, boolean firstPass) {
final Component propComponent = (Component) value;
final Class componentClass;
if (propComponent.isDynamic()) {
componentClass = ReflectionTools.loadClass(Map.class.getCanonicalName(), mainGenerator.getClassLoaderService());
} else {
componentClass = ReflectionTools.loadClass(propComponent.getComponentClassName(), mainGenerator.getClassLoaderService());
}
final CompositeMapperBuilder componentMapper = mapper.addComponent(propertyAuditingData.getPropertyData(), componentClass);
// The property auditing data must be for a component.
final ComponentAuditingData componentAuditingData = (ComponentAuditingData) propertyAuditingData;
// Adding all properties of the component
final Iterator<Property> properties = (Iterator<Property>) propComponent.getPropertyIterator();
while (properties.hasNext()) {
final Property property = properties.next();
final PropertyAuditingData componentPropertyAuditingData = componentAuditingData.getPropertyAuditingData(property.getName());
// Checking if that property is audited
if (componentPropertyAuditingData != null) {
mainGenerator.addValue(parent, property.getValue(), componentMapper, entityName, xmlMappingData, componentPropertyAuditingData, property.isInsertable(), firstPass, false);
}
}
}
use of org.hibernate.envers.internal.entities.mapper.CompositeMapperBuilder in project hibernate-orm by hibernate.
the class AuditMetadataGenerator method generateSecondPass.
@SuppressWarnings({ "unchecked" })
public void generateSecondPass(PersistentClass pc, ClassAuditingData auditingData, EntityXmlMappingData xmlMappingData) {
final String entityName = pc.getEntityName();
LOG.debugf("Generating second-pass auditing mapping for entity %s", entityName);
final CompositeMapperBuilder propertyMapper = entitiesConfigurations.get(entityName).getPropertyMapper();
// Mapping unjoined properties
final Element parent = xmlMappingData.getClassMapping();
addProperties(parent, pc.getUnjoinedPropertyIterator(), propertyMapper, auditingData, entityName, xmlMappingData, false);
// Mapping joins (second pass)
addJoins(pc, propertyMapper, auditingData, entityName, xmlMappingData, false);
}
use of org.hibernate.envers.internal.entities.mapper.CompositeMapperBuilder in project hibernate-orm by hibernate.
the class MiddleEmbeddableComponentMapper method addMiddleEqualToQuery.
protected void addMiddleEqualToQuery(CompositeMapperBuilder compositeMapper, Parameters parameters, String idPrefix1, String prefix1, String idPrefix2, String prefix2) {
for (final Map.Entry<PropertyData, PropertyMapper> entry : compositeMapper.getProperties().entrySet()) {
final String propertyName = entry.getKey().getName();
final PropertyMapper nestedMapper = entry.getValue();
if (nestedMapper instanceof CompositeMapperBuilder) {
addMiddleEqualToQuery((CompositeMapperBuilder) nestedMapper, parameters, idPrefix1, prefix1, idPrefix2, prefix2);
} else if (nestedMapper instanceof ToOneIdMapper) {
((ToOneIdMapper) nestedMapper).addMiddleEqualToQuery(parameters, idPrefix1, prefix1, idPrefix2, prefix2);
} else {
parameters.addWhereOrNullRestriction(prefix1 + '.' + propertyName, false, "=", prefix2 + '.' + propertyName, false);
}
}
}
Aggregations