Skip to content

Commit 01f1158

Browse files
committed
Bootstrap SessionFactory implements InfrastructureProxy interface for resource key unwrapping
Issue: SPR-14379
1 parent f9fec73 commit 01f1158

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-orm-hibernate5/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
4747
import org.hibernate.engine.spi.SessionFactoryImplementor;
4848

49+
import org.springframework.core.InfrastructureProxy;
4950
import org.springframework.core.io.Resource;
5051
import org.springframework.core.io.ResourceLoader;
5152
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -317,7 +318,7 @@ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFac
317318
public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
318319
Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
319320
return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
320-
new Class<?>[] {SessionFactoryImplementor.class},
321+
new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class},
321322
new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
322323
}
323324

@@ -354,6 +355,10 @@ else if (method.getName().equals("hashCode")) {
354355
else if (method.getName().equals("getProperties")) {
355356
return getProperties();
356357
}
358+
else if (method.getName().equals("getWrappedObject")) {
359+
// Call coming in through InfrastructureProxy interface...
360+
return getSessionFactory();
361+
}
357362
// Regular delegation to the target SessionFactory,
358363
// enforcing its full initialization...
359364
return method.invoke(getSessionFactory(), args);

0 commit comments

Comments
 (0)