Hi I need to pass my own ClassLoaderServiceImpl
into Hibernate. The issue is that I cannot figure out how to pass it into Hibernate over Spring Boot. How would I do it?
Here is what I got:
ClassLoaderServiceImpl serviceImpl = new ClassLoaderServiceImpl(customClassLoader);
// Magical code that injects serviceImpl into Spring Boot, which will give it to Hibernate
Any help is much appreciated!
CodePudding user response:
That could be tricky.
- you need to use specific EntityManagerFactoryBuilderImpl constructor to inject your own implementation of
ClassLoaderServiceImpl
spring-orm
uses another constructor which does not fit your needs: SpringHibernateJpaPersistenceProvider - thus, you need to override/inherit SpringHibernateJpaPersistenceProvider- next you need to override HibernateJpaVendorAdapter#getPersistenceProvider
- after that you will need to override boot auto-configurations.