From c9d4305bf191bcc95ceb7c5a4d6db740c71629c0 Mon Sep 17 00:00:00 2001 From: zuchos Date: Wed, 2 Oct 2013 13:46:03 +0200 Subject: [PATCH] HHH-8505: Fixed todos --- .../reader/AuditedPropertiesReader.java | 23 +++---------------- .../mapper/ComponentPropertyMapper.java | 4 ++-- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java index eac3bdf136..cfc9218e7c 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java @@ -319,13 +319,11 @@ public class AuditedPropertiesReader { private void addPropertiesFromDynamicComponent(DynamicComponentSource dynamicComponentSource) { Audited audited = computeAuditConfiguration( dynamicComponentSource.getXClass() ); if ( !fieldAccessedPersistentProperties.isEmpty() ) { - //TODO ŁŻ hmm... for sure ? - throw new MappingException( "Dynamic component cannot have field accessed persistent properties" ); + throw new MappingException( + "Audited dynamic component cannot have properties with access=\"field\" for properties: " + fieldAccessedPersistentProperties + ". \n Change properties access=\"property\", to make it work)" + ); } for ( String property : propertyAccessedPersistentProperties ) { - // If this is not a persistent property, with the same access type as currently checked, - // it's not audited as well. - // If the property was already defined by the subclass, is ignored by superclasses String accessType = AccessType.PROPERTY.getType(); if ( !auditedPropertiesHolder.contains( property ) ) { final Value propertyValue = persistentPropertiesSource.getProperty( property ).getValue(); @@ -345,21 +343,6 @@ public class AuditedPropertiesReader { ); } } - else if ( propertiesGroupMapping.containsKey( property ) ) { - //todo ŁŻ - I'm not sure is that the case that we should handle for dynamic component. - // Retrieve embedded component name based on class field. - final String embeddedName = propertiesGroupMapping.get( property ); - if ( !auditedPropertiesHolder.contains( embeddedName ) ) { - // Manage properties mapped within tag. - final Value propertyValue = persistentPropertiesSource.getProperty( embeddedName ).getValue(); - this.addFromPropertiesGroup( - embeddedName, - new DynamicProperty( dynamicComponentSource, property ), accessType, - (Component) propertyValue, - audited - ); - } - } } } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/ComponentPropertyMapper.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/ComponentPropertyMapper.java index b9887c1d51..a648efba17 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/ComponentPropertyMapper.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/ComponentPropertyMapper.java @@ -50,8 +50,8 @@ public class ComponentPropertyMapper implements PropertyMapper, CompositeMapperB public ComponentPropertyMapper(PropertyData propertyData, Class componentClass) { this.propertyData = propertyData; - //ŁŻ this could be done better - if ( Map.class.equals( componentClass ) ) { + //if class is a map it means that this is dynamic component + if ( Map.class.isAssignableFrom( componentClass ) ) { this.delegate = new MultiDynamicComponentMapper( propertyData ); this.componentClass = HashMap.class; }