Skip to content

Commit

Permalink
Add missing proxy hints for Hibernate native query
Browse files Browse the repository at this point in the history
This commit contributes proxy hints needed by
SharedEntityManagerCreator for
org.hibernate.query.sql.internal.NativeQueryImpl interfaces.

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

Closes gh-29603
  • Loading branch information
sdeleuze committed Aug 18, 2023
1 parent 47b1a2b commit c91708c
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -39,6 +39,8 @@ class EntityManagerRuntimeHints implements RuntimeHintsRegistrar {

private static final String QUERY_SQM_IMPL_CLASS_NAME = "org.hibernate.query.sqm.internal.QuerySqmImpl";

private static final String NATIVE_QUERY_IMPL_CLASS_NAME = "org.hibernate.query.sql.internal.NativeQueryImpl";

@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
if (ClassUtils.isPresent(HIBERNATE_SESSION_FACTORY_CLASS_NAME, classLoader)) {
Expand All @@ -61,5 +63,11 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
}
catch (ClassNotFoundException ignored) {
}
try {
Class<?> clazz = ClassUtils.forName(NATIVE_QUERY_IMPL_CLASS_NAME, classLoader);
hints.proxies().registerJdkProxy(ClassUtils.getAllInterfacesForClass(clazz, classLoader));
}
catch (ClassNotFoundException ignored) {
}
}
}

0 comments on commit c91708c

Please sign in to comment.