DATACMNS-1300 - Improved collection query detection for Iterables.

Previously a custom Iterable implementation would've caused QueryMethod.isCollectionQuery() to return true. We now solely rely on TypeInformation.isCollectionLike() (which checks for exact Iterable, Collection assignability and arrays) after handling potential wrapper types.
This commit is contained in:
Oliver Gierke
2018-04-16 16:19:28 +02:00
parent 5986b4b7af
commit 3676ae0c87
2 changed files with 26 additions and 6 deletions

View File

@@ -181,13 +181,11 @@ public class QueryMethod {
return true;
}
if (QueryExecutionConverters.supports(unwrappedReturnType)
&& QueryExecutionConverters.isSingleValue(unwrappedReturnType)) {
return false;
if (QueryExecutionConverters.supports(unwrappedReturnType)) {
return !QueryExecutionConverters.isSingleValue(unwrappedReturnType);
}
return org.springframework.util.ClassUtils.isAssignable(Iterable.class, unwrappedReturnType)
|| unwrappedReturnType.isArray();
return ClassTypeInformation.from(unwrappedReturnType).isCollectionLike();
}
/**
@@ -289,7 +287,9 @@ public class QueryMethod {
Assert.notEmpty(types, "Types must not be null or empty!");
TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);
returnType = QueryExecutionConverters.isSingleValue(returnType.getType()) ? returnType.getRequiredComponentType()
returnType = QueryExecutionConverters.isSingleValue(returnType.getType()) //
? returnType.getRequiredComponentType() //
: returnType;
for (Class<?> type : types) {