Skip to content

Commit 13d9d5e

Browse files
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.
1 parent cd82d50 commit 13d9d5e

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

Lines changed: 8 additions & 3 deletions
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)