From b189240aaf83bf438981384645bf92bfb185ee98 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 29 Nov 2021 11:47:14 +0100 Subject: [PATCH] Polishing. Original Pull Request: #2420 --- .../context/EntityProjectionIntrospector.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/mapping/context/EntityProjectionIntrospector.java b/src/main/java/org/springframework/data/mapping/context/EntityProjectionIntrospector.java index e3d759718..bc2991a83 100644 --- a/src/main/java/org/springframework/data/mapping/context/EntityProjectionIntrospector.java +++ b/src/main/java/org/springframework/data/mapping/context/EntityProjectionIntrospector.java @@ -102,7 +102,6 @@ public class EntityProjectionIntrospector { false); } - PersistentEntity persistentEntity = mappingContext.getRequiredPersistentEntity(domainType); List> propertyDescriptors = getProperties(null, projectionInformation, returnedTypeInformation, @@ -111,12 +110,13 @@ public class EntityProjectionIntrospector { return EntityProjection.projecting(returnedTypeInformation, domainTypeInformation, propertyDescriptors, true); } - private List> getProperties(@Nullable PropertyPath propertyPath, ProjectionInformation projectionInformation, TypeInformation projectionTypeInformation, PersistentEntity persistentEntity, @Nullable CycleGuard cycleGuard) { List> propertyDescriptors = new ArrayList<>(); + + // TODO: PropertyDescriptor only created for DTO's with getters/setters for (PropertyDescriptor inputProperty : projectionInformation.getInputProperties()) { PersistentProperty persistentProperty = persistentEntity.getPersistentProperty(inputProperty.getName()); @@ -228,6 +228,18 @@ public class EntityProjectionIntrospector { return new EntityProjection<>(mappedType, domainType, properties, false, false); } + /** + * Create a non-projecting variant of a mapped type. + * + * @param mappedType + * @param domainType + * @return + */ + public static EntityProjection nonProjecting(Class type) { + ClassTypeInformation typeInformation = ClassTypeInformation.from(type); + return new EntityProjection<>(typeInformation, typeInformation, Collections.emptyList(), false, false); + } + /** * @return the mapped type used by this type view. */