Add required runtime hint for streaming results.

This commit makes sure we're able to invoke the method required for streaming results.

Resolves: #2848
This commit is contained in:
Christoph Strobl
2023-03-22 07:43:07 +01:00
committed by Greg L. Turnquist
parent c1c014a374
commit 31db4aaf31

View File

@@ -18,7 +18,9 @@ package org.springframework.data.jpa.repository.aot;
import jakarta.persistence.NamedEntityGraph;
import java.util.Arrays;
import java.util.Collections;
import org.springframework.aot.hint.ExecutableMode;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -76,6 +78,12 @@ class JpaRuntimeHints implements RuntimeHintsRegistrar {
.onReachableType(QuerydslPredicateExecutor.class));
}
// streaming results requires reflective access to jakarta.persistence.Query#getResultAsStream
hints.reflection().registerType(jakarta.persistence.Query.class, MemberCategory.INTROSPECT_PUBLIC_METHODS);
hints.reflection().registerType(jakarta.persistence.Query.class, hint -> {
hint.withMethod("getResultStream", Collections.emptyList(), ExecutableMode.INVOKE);
});
hints.reflection().registerType(NamedEntityGraph.class,
hint -> hint.onReachableType(EntityGraph.class).withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
}