An error message (instead of an NPE) when a suprclass of an audited entity is not audited

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18024 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Adam Warski 2009-11-23 15:43:31 +00:00
parent 1a31549ced
commit deabfeb485
1 changed files with 8 additions and 1 deletions

View File

@ -273,7 +273,14 @@ public final class AuditMetadataGenerator {
// Getting the property mapper of the parent - when mapping properties, they need to be included // Getting the property mapper of the parent - when mapping properties, they need to be included
String parentEntityName = pc.getSuperclass().getEntityName(); 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); ExtendedPropertyMapper propertyMapper = new SubclassPropertyMapper(new MultiPropertyMapper(), parentPropertyMapper);
return Triple.make(class_mapping, propertyMapper, parentEntityName); return Triple.make(class_mapping, propertyMapper, parentEntityName);