Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalSessionFactoryBean (hibernate5) does not correctly pass custom ClassLoader to Hibernate [SPR-13879] #18452

Closed
spring-projects-issues opened this issue Jan 21, 2016 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 21, 2016

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:

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

The irony is that AvailableSettings.CLASSLOADERS is new in 5.0... What exactly is that setting good for if it doesn't work for such purposes??

We can do the applyClassLoader thing, of course; thanks for pointing that out. It's just a little unfortunate with respect to the lifecycle of a given MetadataSources object which we accept as of 4.3 now...

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants