From 86497dfa67c94c67b97bc3f1fb237385351690c5 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Fri, 22 Sep 2023 12:43:08 +0200 Subject: [PATCH] Add missing runtime hints for `ReactiveBeforeBindCallback` See #2798. --- .../data/neo4j/aot/Neo4jRuntimeHints.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/org/springframework/data/neo4j/aot/Neo4jRuntimeHints.java b/src/main/java/org/springframework/data/neo4j/aot/Neo4jRuntimeHints.java index f17b6db05..879c71ce0 100644 --- a/src/main/java/org/springframework/data/neo4j/aot/Neo4jRuntimeHints.java +++ b/src/main/java/org/springframework/data/neo4j/aot/Neo4jRuntimeHints.java @@ -21,10 +21,17 @@ import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; import org.springframework.data.neo4j.core.mapping.callback.AfterConvertCallback; import org.springframework.data.neo4j.core.mapping.callback.BeforeBindCallback; +import org.springframework.data.neo4j.core.mapping.callback.ReactiveBeforeBindCallback; import org.springframework.data.neo4j.core.schema.GeneratedValue; import org.springframework.data.neo4j.core.support.UUIDStringGenerator; +import org.springframework.data.neo4j.repository.query.QuerydslNeo4jPredicateExecutor; +import org.springframework.data.neo4j.repository.query.ReactiveQuerydslNeo4jPredicateExecutor; import org.springframework.data.neo4j.repository.query.SimpleQueryByExampleExecutor; +import org.springframework.data.neo4j.repository.query.SimpleReactiveQueryByExampleExecutor; import org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository; +import org.springframework.data.neo4j.repository.support.SimpleReactiveNeo4jRepository; +import org.springframework.data.querydsl.QuerydslUtils; +import org.springframework.data.util.ReactiveWrappers; import org.springframework.lang.Nullable; import java.util.Arrays; @@ -51,5 +58,31 @@ public class Neo4jRuntimeHints implements RuntimeHintsRegistrar { ), builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS)); + + if (ReactiveWrappers.isAvailable(ReactiveWrappers.ReactiveLibrary.PROJECT_REACTOR)) { + hints.reflection().registerTypes( + Arrays.asList( + TypeReference.of(SimpleReactiveNeo4jRepository.class), + TypeReference.of(SimpleReactiveQueryByExampleExecutor.class), + TypeReference.of(ReactiveBeforeBindCallback.class) + ), + builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS)); + } + + if (QuerydslUtils.QUERY_DSL_PRESENT) { + registerQuerydslHints(hints); + } + } + + private static void registerQuerydslHints(RuntimeHints hints) { + + hints.reflection().registerType(QuerydslNeo4jPredicateExecutor.class, + MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); + + if (ReactiveWrappers.isAvailable(ReactiveWrappers.ReactiveLibrary.PROJECT_REACTOR)) { + hints.reflection().registerType(ReactiveQuerydslNeo4jPredicateExecutor.class, + MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); + } + } }