Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate + spring version compatibility

Tags:

H, I want to upgrade Spring libraries in my web app. Since I am using Hibernate as well, I wanted to know if there is a way I could find which version of Hibernate is compatible with a specific version of Spring.

I have already searched google and read similar posts of SO, but I want to know if there is a way to compare different versions of libraries/framework.

My current setup:

Spring V2.5 Hibernate : org.hibernate.hibernate 3.2.6.ga             org.hibernate.hibernate-annotations 3.3.1.ga 

The latest version of Hibernate available in my repository is 3.5.4-FINAL and 3.5.6-FINAL for the above artifacts

UPDATE I am getting this error after upgrading Hibernate to 3.5.4 from 3.2 with Spring 2.5 (unchanged)

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'  defined in class path resource [applicationContext-hibernate.xml]: Initialization of bean failed;  nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory'  defined in class path resource [applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError:  Implementing class         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)         at java.security.AccessController.doPrivileged(Native Method)         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)         at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)         at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:597)         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)         at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)         at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)         at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)         at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)         at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)         at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)         at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)         at org.apache.catalina.core.StandardService.start(StandardService.java:525)         at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)         at org.apache.catalina.startup.Catalina.start(Catalina.java:595)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)         at java.lang.reflect.Method.invoke(Method.java:597)         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 
like image 430
Rakesh Avatar asked Aug 02 '13 12:08

Rakesh


1 Answers

You can check this out in the spring-orm Maven POM.

For example to check the version of Hibernate used by Spring 3.2.3.RELEASE, you can issue the following shell command:

grep -A 1 hibernate- ~/.m2/repository/org/springframework/spring-orm/3.2.3.RELEASE/spring-orm-3.2.3.RELEASE.pom 

The command above would result in the following output:

      <artifactId>hibernate-annotations</artifactId>       <version>3.4.0.GA</version> --       <artifactId>hibernate-core</artifactId>       <version>4.1.9.Final</version> --       <artifactId>hibernate-core</artifactId>       <version>3.3.2.GA</version> --       <artifactId>hibernate-entitymanager</artifactId>       <version>4.1.9.Final</version> --       <artifactId>hibernate-entitymanager</artifactId>       <version>3.4.0.GA</version> 

And from the output above we can deduce that Spring 3.2.3.RELEASE supports Hibernate 4.1.9.Final and 3.3.2.GA .

Of course you can try to use Spring with different version of Hibernate, but the versions from the POM are the less likely to give you some issues.

like image 106
Henryk Konsek Avatar answered Nov 16 '22 10:11

Henryk Konsek