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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user