DATAJPA-438 - Removed custom ConversionService handling in JpaQueryExecution.

Spring Data Commons introduced a generic mechanism to post process the results of a repository method execution to potentially mitigate type differences between the result of the execution and the declared method return type. Thus we can remove the custom ConversionService usage implemented in JpaQueryExecution.

Related tickets: DATACMNS-483.
This commit is contained in:
Oliver Gierke
2014-04-22 14:27:50 +02:00
parent 7c6f4528ef
commit aff479d4a4

View File

@@ -23,8 +23,6 @@ import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -44,8 +42,6 @@ import org.springframework.util.Assert;
*/
public abstract class JpaQueryExecution {
private static final ConversionService conversionService = new DefaultConversionService();
/**
* Executes the given {@link AbstractStringBasedJpaQuery} with the given {@link ParameterBinder}.
*
@@ -58,26 +54,11 @@ public abstract class JpaQueryExecution {
Assert.notNull(query);
Assert.notNull(values);
Object result;
try {
result = doExecute(query, values);
return doExecute(query, values);
} catch (NoResultException e) {
return null;
}
if (result == null) {
return result;
}
JpaQueryMethod queryMethod = query.getQueryMethod();
Class<?> requiredType = queryMethod.getReturnType();
if (void.class.equals(requiredType) || requiredType.isAssignableFrom(result.getClass())) {
return result;
}
return conversionService.convert(result, requiredType);
}
/**