mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-09 08:40:39 +00:00
Add missing proxy hints for Hibernate 8's MutationOrSelectionQuery
Prior to this commit, Hibernate 8 types extending `MutationOrSelectionQuery` would fail proxying at runtime in native images because reflection hints were not registered at build time. While the `MutationOrSelectionQueryImpl` case can be solved with an additional proxy hint, `NativeMutationOrSelectionQueryImpl` is impossible to solve that way due to multi interface mismatch. This was found in gh-36878 and handled with a fallback proxy. In this case, native image will throw a `MissingReflectionRegistrationError` - but obviously we cannot depend on this type in JVM applications. `MissingReflectionRegistrationError` extends `LinkageError`, which we will use along IllegalArgumentException` to detect that the proxying operation failed and that we should use the fallback. This commit also register a proxy hint for the said fallback. Fixes gh-37251
This commit is contained in:
+6
@@ -17,6 +17,7 @@
|
||||
package org.springframework.orm.jpa;
|
||||
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import jakarta.persistence.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.StatelessSession;
|
||||
@@ -60,6 +61,11 @@ class EntityManagerRuntimeHintsTests {
|
||||
assertThat(RuntimeHintsPredicates.proxies().forInterfaces(StatelessSession.class)).accepts(this.hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
void entityManagerFactoryHasFallbackQueryProxyHints() {
|
||||
assertThat(RuntimeHintsPredicates.proxies().forInterfaces(Query.class)).accepts(this.hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
void entityManagerFactoryHasReflectionHints() {
|
||||
assertThat(RuntimeHintsPredicates.reflection().onMethodInvocation(EntityManagerFactory.class, "getCriteriaBuilder")).accepts(this.hints);
|
||||
|
||||
Reference in New Issue
Block a user