Skip to content

Commit b189240

Browse files
mp911dechristophstrobl
authored andcommitted
Polishing.
Original Pull Request: #2420
1 parent caa8c6a commit b189240

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public <M, D> EntityProjection<M, D> introspect(Class<M> mappedType, Class<D> do
102102
false);
103103
}
104104

105-
106105
PersistentEntity<?, ?> persistentEntity = mappingContext.getRequiredPersistentEntity(domainType);
107106
List<PropertyProjection<?, ?>> propertyDescriptors = getProperties(null, projectionInformation,
108107
returnedTypeInformation,
@@ -111,12 +110,13 @@ public <M, D> EntityProjection<M, D> introspect(Class<M> mappedType, Class<D> do
111110
return EntityProjection.projecting(returnedTypeInformation, domainTypeInformation, propertyDescriptors, true);
112111
}
113112

114-
115113
private List<PropertyProjection<?, ?>> getProperties(@Nullable PropertyPath propertyPath,
116114
ProjectionInformation projectionInformation, TypeInformation<?> projectionTypeInformation,
117115
PersistentEntity<?, ?> persistentEntity, @Nullable CycleGuard cycleGuard) {
118116

119117
List<PropertyProjection<?, ?>> propertyDescriptors = new ArrayList<>();
118+
119+
// TODO: PropertyDescriptor only created for DTO's with getters/setters
120120
for (PropertyDescriptor inputProperty : projectionInformation.getInputProperties()) {
121121

122122
PersistentProperty<?> persistentProperty = persistentEntity.getPersistentProperty(inputProperty.getName());
@@ -228,6 +228,18 @@ public static <M, D> EntityProjection<M, D> nonProjecting(TypeInformation<M> map
228228
return new EntityProjection<>(mappedType, domainType, properties, false, false);
229229
}
230230

231+
/**
232+
* Create a non-projecting variant of a mapped type.
233+
*
234+
* @param mappedType
235+
* @param domainType
236+
* @return
237+
*/
238+
public static <T> EntityProjection<T, T> nonProjecting(Class<T> type) {
239+
ClassTypeInformation<T> typeInformation = ClassTypeInformation.from(type);
240+
return new EntityProjection<>(typeInformation, typeInformation, Collections.emptyList(), false, false);
241+
}
242+
231243
/**
232244
* @return the mapped type used by this type view.
233245
*/

0 commit comments

Comments
 (0)