|
46 | 46 | import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
|
47 | 47 | import org.hibernate.engine.spi.SessionFactoryImplementor;
|
48 | 48 |
|
| 49 | +import org.springframework.core.InfrastructureProxy; |
49 | 50 | import org.springframework.core.io.Resource;
|
50 | 51 | import org.springframework.core.io.ResourceLoader;
|
51 | 52 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
@@ -317,7 +318,7 @@ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFac
|
317 | 318 | public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
|
318 | 319 | Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
|
319 | 320 | return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
|
320 |
| - new Class<?>[] {SessionFactoryImplementor.class}, |
| 321 | + new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class}, |
321 | 322 | new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
|
322 | 323 | }
|
323 | 324 |
|
@@ -354,6 +355,10 @@ else if (method.getName().equals("hashCode")) {
|
354 | 355 | else if (method.getName().equals("getProperties")) {
|
355 | 356 | return getProperties();
|
356 | 357 | }
|
| 358 | + else if (method.getName().equals("getWrappedObject")) { |
| 359 | + // Call coming in through InfrastructureProxy interface... |
| 360 | + return getSessionFactory(); |
| 361 | + } |
357 | 362 | // Regular delegation to the target SessionFactory,
|
358 | 363 | // enforcing its full initialization...
|
359 | 364 | return method.invoke(getSessionFactory(), args);
|
|
0 commit comments