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