Description
Jon Mann opened SPR-13879 and commented
We are using hibernate5.LocalSessionFactoryBean (with Hibernate v5.0.5) and having difficulties passing a custom ClassLoader to Hibernate.
In particular LocalSessionFactoryBuilder uses the following code in its constructor:
getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader()));
But if you check the usages of AvailableSettings.CLASSLOADERS in Hibernate 5 you will find that it is only used by the legacy and unused method fromConfigSettings() in ClassLoaderServiceImpl. Therefore I believe this code effectively does nothing.
I believe that LocalSessionFactoryBuilder should actually pass the ClassLoader to the parent Hibernate Configuration constructor using something like this:
super(new BootstrapServiceRegistryBuilder().applyClassLoader(resourceLoader.getClassLoader()).build())
Hopefully this makes some sense.
Thanks to the Spring team for a great product.
Affects: 4.2.4
Issue Links:
- Hibernate5 metadata access [SPR-13710] #18285 Hibernate5 metadata access
- Proper load-time weaving support for Hibernate 5 [SPR-13886] #18459 Proper load-time weaving support for Hibernate 5
- Add setMultiTenantConnectionProvider to org.springframework.orm.hibernate5.LocalSessionFactoryBean [SPR-14072] #18644 Add setMultiTenantConnectionProvider to org.springframework.orm.hibernate5.LocalSessionFactoryBean