From 69b32abf1c10d2c1b5e9e966977860ee3400e360 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 14 Jul 2015 13:22:54 +0200 Subject: [PATCH] DATAJPA-757 - Tweaked conversion service in JpaQueryExecution. With 83a3db we switched from a GenericConversionService to DefaultConversionService to be able to transparently convert non-Long results for count query executions into Longs. Unfortunately the additional converters registered in DefaultConversionService now also kick in on the early conversion attempt. This is especially problematic for collection results that are wrapped into a (Completable)Future as the CollectionToObjectConverter opts into conversions from an arbitrary collection to objects trying to figure out element type conversion later on. We now explicitly deregister the conversions from Collection to Object (which is the convertible pair that CollectionToObjectConverter registers for) to avoid the conversion service to try to convert those values. --- .../data/jpa/repository/query/JpaQueryExecution.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java index 521079803..5ebcac88d 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java @@ -15,6 +15,7 @@ */ package org.springframework.data.jpa.repository.query; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -41,7 +42,7 @@ import org.springframework.util.Assert; /** * Set of classes to contain query execution strategies. Depending (mostly) on the return type of a * {@link org.springframework.data.repository.query.QueryMethod} a {@link AbstractStringBasedJpaQuery} can be executed - * in various flavours. + * in various flavors. * * @author Oliver Gierke * @author Thomas Darimont @@ -53,6 +54,7 @@ public abstract class JpaQueryExecution { static { ConfigurableConversionService conversionService = new DefaultConversionService(); + conversionService.removeConvertible(Collection.class, Object.class); conversionService.addConverter(JpaResultConverters.BlobToByteArrayConverter.INSTANCE); CONVERSION_SERVICE = conversionService;