Sunday, 29 July 2012

Upgrade Hibernate from 3.1.3 to 3.6.10.Final using Maven

At the time of writing Hibernate is well into its 4.X releases with 5.X in sight so if you are looking to migrate from 3.x to 4.x read this or If you need a specific migration guide look here.

In my case I needed to migrate our application from 3.1.3 to 3.6.10.for which I have detailed the steps below.


  • Make sure that you have the necessary repositories to download the required Jars. You might need.


       mvn-public
       MVNRepository
       http://mvnrepository.com


       repository.jboss.org-public
       JBoss.org Maven repository
       https://repository.jboss.org/nexus/content/groups/public
  


  • Add the following dependencies into your pom.xml
   
  
   org.hibernate
   hibernate-core
   3.6.10.Final
  
  
  
   javassist
   javassist
   3.12.1.GA
  

Since Hibernate 3.4.X onwards, Hibernate switched to SL4J, you'll need:


   org.slf4j
   slf4j-log4j12
   1.5.6
  
  
   log4j
   log4j
   1.2.16
  

Now, configure your connection poolDownload the c3p0-0.9.1.2.jar from here and load it into your Tomcat/lib along with your MySQL driver jar.


Add the following configuration settings in your Hibernate (.properties or .cfg.) file.

5
20
300
50
3000

That's it !!
You WAR/lib should have the following jars present post-migration.
  • commons-collections-3.1.jar
  • hibernate-commons-annotations-3.2.0.Final.jar
  • hibernate-core-3.6.10.Final.jar
  • hibernate-jpa-2.0-api-1.0.1.Final.jar

  • javassist-3.12.1.GA.jar
  • jta-1.1.jar
  • slf4j-api-1.5.6.jar
  • slf4j-log4j12-1.5.6.jar


No comments: