From c9fc0c9f366b49f418d50cc44511511017920d42 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 31 May 2016 18:10:39 +0200 Subject: [PATCH] =?UTF-8?q?DATACMNS-856,=20DATACMNS-685=20-=20Made=20ToEnt?= =?UTF-8?q?ityConverter.matches(=E2=80=A6)=20less=20offensive.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ToEntityConverter.matches(…) now doesn't throw an exception anymore as it might be picked up by classpath scanning an the exception previously thrown causing the entire conversion attempt to abort. We're now rather inspecting the ToEntityConverter in case the target type is a repository managed one and the ToIdConverter otherwise. --- .../support/DomainClassConverter.java | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/springframework/data/repository/support/DomainClassConverter.java b/src/main/java/org/springframework/data/repository/support/DomainClassConverter.java index 217ab033d..7362b247b 100644 --- a/src/main/java/org/springframework/data/repository/support/DomainClassConverter.java +++ b/src/main/java/org/springframework/data/repository/support/DomainClassConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2015 the original author or authors. + * Copyright 2008-2016 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. @@ -39,8 +39,8 @@ import org.springframework.util.StringUtils; * @author Oliver Gierke * @author Thomas Darimont */ -public class DomainClassConverter implements - ConditionalGenericConverter, ApplicationContextAware { +public class DomainClassConverter + implements ConditionalGenericConverter, ApplicationContextAware { private final T conversionService; private Repositories repositories = Repositories.NONE; @@ -73,8 +73,9 @@ public class DomainClassConverter rawIdType = repositories.getRepositoryInformationFor(targetType.getType()).getIdType(); - if (sourceType.equals(TypeDescriptor.valueOf(rawIdType)) - || conversionService.canConvert(sourceType.getType(), rawIdType)) { - return true; - } - - // Throw an exception to indicate it should have matched an no further resolution should be tried - throw new ConversionMatchAbbreviationException(); + return sourceType.equals(TypeDescriptor.valueOf(rawIdType)) + || conversionService.canConvert(sourceType.getType(), rawIdType); } } @@ -246,7 +239,4 @@ public class DomainClassConverter