I have java spring (v2.7.1) application and I want to test my database (H2 DB) layer. I have the following query:
@Query(value =
"SELECT something.c1 " +
"FROM " +
"(SELECT Count(c1) AS Count, c1 " +
"FROM Table1 " +
"WHERE c2 IN (:thing2Ids) " +
"GROUP BY c1) " +
"AS something " +
"WHERE something.Count = :thingCount",
nativeQuery = true)
List<UUID> findThings(@Param("thingCount") Integer thingCount, @Param("thing2Ids") List<String> thing2Ids);
At the end of my query I want to get back a list of UUIDs. When I run this query (i.e. I build and run the application and call this method) it is working fine. But when I try to test this, I got the following error:
org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.util.ArrayList<?>] to type [@org.springframework.data.jpa.repository.Query java.util.List<java.util.UUID>] for value '[[somevalue1, [somevalue2]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [byte[]] to type [@org.springframework.data.jpa.repository.Query java.util.UUID]
Why my code needs converter at testing time but runtim don't? I don't get the point here. I have checked this, this articles already but I don't want to write a converter just because of testing my app. Anyone did come across similar case?