DATACMNS-460 - Repository metadata now supports array return types for query methods.

Added array checks to AbstractRepositoryMetadata.getReturnedDomainClass() to detect array component types. QueryMethod now considers methods returning arrays to be collection query methods.
This commit is contained in:
Oliver Gierke
2014-03-05 08:08:08 +01:00
parent 1805aad718
commit ae03feab42
4 changed files with 44 additions and 3 deletions

View File

@@ -60,7 +60,9 @@ public abstract class AbstractRepositoryMetadata implements RepositoryMetadata {
TypeInformation<?> returnTypeInfo = typeInformation.getReturnType(method);
Class<?> rawType = returnTypeInfo.getType();
return Iterable.class.isAssignableFrom(rawType) ? returnTypeInfo.getComponentType().getType() : rawType;
boolean needToUnwrap = Iterable.class.isAssignableFrom(rawType) || rawType.isArray();
return needToUnwrap ? returnTypeInfo.getComponentType().getType() : rawType;
}
/*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2013 the original author or authors.
* Copyright 2008-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@ public class QueryMethod {
Class<?> returnType = method.getReturnType();
return !(isPageQuery() || isSliceQuery())
&& org.springframework.util.ClassUtils.isAssignable(Iterable.class, returnType);
&& org.springframework.util.ClassUtils.isAssignable(Iterable.class, returnType) || returnType.isArray();
}
/**