Browse Source

Add missing Hibernate 6.2 proxy hints

This commit contributes proxy hints needed by
SharedEntityManagerCreator for
org.hibernate.query.sqm.internal.QuerySqmImpl interfaces.

Until Hibernate 6.1, those hints were erroneously provided
at GraalVM reachability metadata level. As of Hibernate 6.2,
they are not, hence the need to contribute them at Spring
Framework level.

A related smoke test has been contributed via
spring-projects/spring-aot-smoke-tests#188.

Closes gh-31050
pull/31496/head
Sébastien Deleuze 1 year ago
parent
commit
78a73e5f57
  1. 8
      spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerRuntimeHints.java

8
spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerRuntimeHints.java

@ -37,6 +37,8 @@ class EntityManagerRuntimeHints implements RuntimeHintsRegistrar { @@ -37,6 +37,8 @@ class EntityManagerRuntimeHints implements RuntimeHintsRegistrar {
private static final String ENTITY_MANAGER_FACTORY_CLASS_NAME = "jakarta.persistence.EntityManagerFactory";
private static final String QUERY_SQM_IMPL_CLASS_NAME = "org.hibernate.query.sqm.internal.QuerySqmImpl";
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
if (ClassUtils.isPresent(HIBERNATE_SESSION_FACTORY_CLASS_NAME, classLoader)) {
@ -53,5 +55,11 @@ class EntityManagerRuntimeHints implements RuntimeHintsRegistrar { @@ -53,5 +55,11 @@ class EntityManagerRuntimeHints implements RuntimeHintsRegistrar {
Collections.emptyList(), ExecutableMode.INVOKE);
});
}
try {
Class<?> clazz = ClassUtils.forName(QUERY_SQM_IMPL_CLASS_NAME, classLoader);
hints.proxies().registerJdkProxy(ClassUtils.getAllInterfacesForClass(clazz, classLoader));
}
catch (ClassNotFoundException ignored) {
}
}
}

Loading…
Cancel
Save