DATACMNS-1352 - Report InvalidPersistentPropertyPath on non-resolvable entities.

We now throw InvalidPersistentPropertyPath during property path resolution if an intermediate path segment cannot resolve an entity to resolve the next segment. This can be caused when a non-entity typed property (e.g. List<Object>) is used within the property path and the path resolution attempts to resolve a property path on the non-entity typed property. Previously, resolution failed with NullPointerException.
This commit is contained in:
Mark Paluch
2018-07-10 12:38:37 +02:00
committed by Oliver Gierke
parent 9ab497f431
commit 98c1aac7d7
2 changed files with 35 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 by the original author(s).
* Copyright 2011-2018 by the original author(s).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -269,7 +269,20 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
path = path.append(persistentProperty);
if (iterator.hasNext()) {
current = getPersistentEntity(persistentProperty.getTypeInformation().getActualType());
TypeInformation<?> actualType = persistentProperty.getTypeInformation().getActualType();
current = getPersistentEntity(actualType);
if (current == null) {
String source = StringUtils.collectionToDelimitedString(parts, ".");
String resolvedPath = path.toDotPath();
String unresolved = iterator.next();
throw new InvalidPersistentPropertyPath(source, persistentProperty.getTypeInformation(), unresolved,
resolvedPath, String.format("No entity %s found for property %s on %s !", actualType.getType().getName(),
segment, persistentProperty.getOwner().getName()));
}
}
}