Skip to content

Commit 31db4aa

Browse files
christophstroblgregturn
authored andcommitted
Add required runtime hint for streaming results.
This commit makes sure we're able to invoke the method required for streaming results. Resolves: #2848
1 parent c1c014a commit 31db4aa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/aot/JpaRuntimeHints.java

+8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import jakarta.persistence.NamedEntityGraph;
1919

2020
import java.util.Arrays;
21+
import java.util.Collections;
2122

23+
import org.springframework.aot.hint.ExecutableMode;
2224
import org.springframework.aot.hint.MemberCategory;
2325
import org.springframework.aot.hint.RuntimeHints;
2426
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -76,6 +78,12 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
7678
.onReachableType(QuerydslPredicateExecutor.class));
7779
}
7880

81+
// streaming results requires reflective access to jakarta.persistence.Query#getResultAsStream
82+
hints.reflection().registerType(jakarta.persistence.Query.class, MemberCategory.INTROSPECT_PUBLIC_METHODS);
83+
hints.reflection().registerType(jakarta.persistence.Query.class, hint -> {
84+
hint.withMethod("getResultStream", Collections.emptyList(), ExecutableMode.INVOKE);
85+
});
86+
7987
hints.reflection().registerType(NamedEntityGraph.class,
8088
hint -> hint.onReachableType(EntityGraph.class).withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
8189
}

0 commit comments

Comments
 (0)