Description
Hello Spring Data JPA team,
I hope that you agree with me that the goal of your project is to provide a piece of software that supports any JPA 2 compliant provider, independent of whether it is the latest and greatest release or whether it might still be an older version of e.g. Hibernate.
In our case, due to the fact that we are tied to JBoss EAP 7.4 as the deployment platform, we mandatorily need to use Hibernate 5.3.x (5.3.23.Final-redhat-00001 as of 7.4.1.GA) as the JPA provider.
But it turns out that due to the fix for #2330 (#2330; 87da84b), Spring Data JPA no longer runs on any Hibernate version before 5.4.0, as the Spring Data JPA "org.springframework.data.jpa.provider.PersistenceProvider" for Hibernate, in its method getIdClassAttributes(PersistenceProvider.java:106), tries to access Hibernate class "org.hibernate.metamodel.model.domain.spi.IdentifiableTypeDescriptor" - but this class is only present in Hibernate versions 5.4.0 or newer.
This class has only been introduced into Hibernate ORM by the commit for "HHH-12713 - Make EntityGraph creation more convenient" (hibernate/hibernate-orm@d0fb16d), but is not existing in any Hibernate version before 5.4, which means when trying to use a current Spring Data JPA build (starting from 2.5.6) to access Hibernate version 5.3.x, you will get the following exception:
Caused by: java.lang.NoClassDefFoundError: org/hibernate/metamodel/model/domain/spi/IdentifiableTypeDescriptor
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.provider.PersistenceProvider$1.getIdClassAttributes(PersistenceProvider.java:106)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata.<init>(JpaMetamodelEntityInformation.java:271)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:89)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:232)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:181)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:164)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:75)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:322)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.util.Lazy.getNullable(Lazy.java:230)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.util.Lazy.get(Lazy.java:114)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:328)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 53 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.metamodel.model.domain.spi.IdentifiableTypeDescriptor from [Module "deployment.ndm-bnb-adminconsole-0.0.1-SNAPSHOT.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 69 more
Can you please fix the PersistenceProvider implementation to still support older Hibernate releases as well (and fall back to its previous behaviour when it detects a Hibernate version < 5.4 which does not provide the class that it is trying to access)?
Many thanks for listening!
Andreas