HHH-13696 Use PU Info Classloader when booting in OsgiPersistenceProvider

This commit is contained in:
Kaja Mohideen 2019-09-06 20:07:56 +05:30 committed by Sanne Grinovero
parent 1dd787eaa1
commit 051a7d9b7c
1 changed files with 9 additions and 2 deletions

View File

@ -92,8 +92,15 @@ public class OsgiPersistenceProvider extends HibernatePersistenceProvider {
osgiClassLoader.addClassLoader( info.getClassLoader() ); osgiClassLoader.addClassLoader( info.getClassLoader() );
return Bootstrap.getEntityManagerFactoryBuilder( info, settings, ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) ).build(); try {
Thread.currentThread().setContextClassLoader(info.getClassLoader());
return Bootstrap.getEntityManagerFactoryBuilder( info, settings,
new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) ).build();
}
finally {
Thread.currentThread().setContextClassLoader(prevCL);
}
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")