Skip to content

Commit b51bee7

Browse files
christophstroblmp911de
authored andcommitted
Use contextual information when creating PersistentPropertyPaths.
In oder to preserve contextual information the PersistentPropertyPathFactory now obtains EntityInformation for properties from the MappingContext via their PersistentProperty representation instead of plain the TypeInformation as the former contains more information about the actual type and signatures. Closes #2293. Original pull request: #2294.
1 parent 54f2d15 commit b51bee7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/org/springframework/data/mapping/context/PersistentPropertyPathFactory.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ private Pair<DefaultPersistentPropertyPath<P>, E> getPair(DefaultPersistentPrope
222222
return null;
223223
}
224224

225-
TypeInformation<?> type = property.getTypeInformation().getRequiredActualType();
226-
return Pair.of(path.append(property), iterator.hasNext() ? context.getRequiredPersistentEntity(type) : entity);
225+
return Pair.of(path.append(property), iterator.hasNext() ? context.getRequiredPersistentEntity(property) : entity);
227226
}
228227

229228
private <T> Collection<PersistentPropertyPath<P>> from(TypeInformation<T> type, Predicate<? super P> filter,
@@ -236,6 +235,12 @@ private <T> Collection<PersistentPropertyPath<P>> from(TypeInformation<T> type,
236235
}
237236

238237
E entity = context.getRequiredPersistentEntity(actualType);
238+
return from(entity, filter, traversalGuard, basePath);
239+
}
240+
241+
private Collection<PersistentPropertyPath<P>> from(E entity, Predicate<? super P> filter, Predicate<P> traversalGuard,
242+
DefaultPersistentPropertyPath<P> basePath) {
243+
239244
Set<PersistentPropertyPath<P>> properties = new HashSet<>();
240245

241246
PropertyHandler<P> propertyTester = persistentProperty -> {
@@ -254,7 +259,7 @@ private <T> Collection<PersistentPropertyPath<P>> from(TypeInformation<T> type,
254259
}
255260

256261
if (traversalGuard.and(IS_ENTITY).test(persistentProperty)) {
257-
properties.addAll(from(typeInformation, filter, traversalGuard, currentPath));
262+
properties.addAll(from(context.getPersistentEntity(persistentProperty), filter, traversalGuard, currentPath));
258263
}
259264
};
260265

0 commit comments

Comments
 (0)