From 71ad509e79d333cd31703d515003541a8bf6fb3f Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Thu, 15 Sep 2022 11:52:21 +0200 Subject: [PATCH] Add runtime hint for repository Query annotation. The annotations default values are evaluated so we need it to be present no matter if used or not. See: #2497 --- .../org/springframework/data/jpa/aot/JpaRuntimeHints.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/aot/JpaRuntimeHints.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/aot/JpaRuntimeHints.java index cc059657c..a8026d6eb 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/aot/JpaRuntimeHints.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/aot/JpaRuntimeHints.java @@ -23,6 +23,7 @@ import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; import org.springframework.data.jpa.domain.support.AuditingBeanFactoryPostProcessor; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; @@ -55,5 +56,8 @@ public class JpaRuntimeHints implements RuntimeHintsRegistrar { hints.reflection().registerType(TypeReference.of(SimpleJpaRepository.class), hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS)); + + // needs to present for evaluating default attribute values in JpaQueryMethod + hints.reflection().registerType(Query.class, hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)); } }