From 4a38d032afdf96fcd7edbb046fc93ad2fd339da6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 16 Nov 2023 14:40:13 +0000 Subject: [PATCH] Restore use of avg in JPA smoke test Closes gh-34895 --- .../main/java/smoketest/data/jpa/service/HotelRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/main/java/smoketest/data/jpa/service/HotelRepository.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/main/java/smoketest/data/jpa/service/HotelRepository.java index 488b362f06..0ca78fd2bd 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/main/java/smoketest/data/jpa/service/HotelRepository.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/src/main/java/smoketest/data/jpa/service/HotelRepository.java @@ -32,7 +32,8 @@ interface HotelRepository extends Repository { Hotel findByCityAndName(City city, String name); - @Query("select h.city as city, h.name as name " + "from Hotel h where h.city = ?1 group by h") + @Query("select h.city as city, h.name as name, avg(cast(r.rating as Integer)) as averageRating " + + "from Hotel h left outer join h.reviews r where h.city = ?1 group by h") Page findByCity(City city, Pageable pageable); @Query("select r.rating as rating, count(r) as count "