DATACMNS-385 - Fixed repository method matching for iterable entities.

When matching the save(Iterable<T>) method of CrudRepository for an entity implementing Iterable we accidentally determined CrudRepository.save(T) as target method if the entity type under consideration implements Iterable.

We now explicitly check for the parameter type not being Iterable when matching the domain type generics in matchesGenericType(…).
This commit is contained in:
Oliver Gierke
2013-10-23 18:23:56 +02:00
parent 55be70d911
commit 8e9b4f78a0
2 changed files with 52 additions and 2 deletions

View File

@@ -184,7 +184,7 @@ class DefaultRepositoryInformation extends AbstractRepositoryMetadata implements
* @return
*/
private boolean isQueryMethodCandidate(Method method) {
return isQueryAnnotationPresentOn(method) || (!isCustomMethod(method) && !isBaseClassMethod(method));
return isQueryAnnotationPresentOn(method) || !isCustomMethod(method) && !isBaseClassMethod(method);
}
/**
@@ -352,7 +352,13 @@ class DefaultRepositoryInformation extends AbstractRepositoryMetadata implements
Type boundType = variable.getBounds()[0];
String referenceName = boundType instanceof TypeVariable ? boundType.toString() : variable.toString();
if (DOMAIN_TYPE_NAME.equals(referenceName) && parameterType.isAssignableFrom(entityType)) {
boolean isDomainTypeVariableReference = DOMAIN_TYPE_NAME.equals(referenceName);
boolean parameterMatchesEntityType = parameterType.isAssignableFrom(entityType);
// We need this check to besure not to match save(Iterable) for entities implementing Iterable
boolean isNotIterable = !parameterType.equals(Iterable.class);
if (isDomainTypeVariableReference && parameterMatchesEntityType && isNotIterable) {
return true;
}