Author: adamw
Date: 2009-11-23 10:43:31 -0500 (Mon, 23 Nov 2009)
New Revision: 18024
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
Log:
An error message (instead of an NPE) when a suprclass of an audited entity is not audited
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-11-23
11:38:18 UTC (rev 18023)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-11-23
15:43:31 UTC (rev 18024)
@@ -273,7 +273,14 @@
// Getting the property mapper of the parent - when mapping properties, they need
to be included
String parentEntityName = pc.getSuperclass().getEntityName();
- ExtendedPropertyMapper parentPropertyMapper =
entitiesConfigurations.get(parentEntityName).getPropertyMapper();
+
+ EntityConfiguration parentConfiguration =
entitiesConfigurations.get(parentEntityName);
+ if (parentConfiguration == null) {
+ throw new MappingException("Entity '" + pc.getEntityName() +
"' is audited, but its superclass: '" +
+ parentEntityName + "' is not.");
+ }
+
+ ExtendedPropertyMapper parentPropertyMapper =
parentConfiguration.getPropertyMapper();
ExtendedPropertyMapper propertyMapper = new SubclassPropertyMapper(new
MultiPropertyMapper(), parentPropertyMapper);
return Triple.make(class_mapping, propertyMapper, parentEntityName);