Saturday, October 1, 2011

How to use Hibernate 3 as JPA provider in JBoss AS7


Jboss AS7 come with Hibernate 4 (even if it still in beta :-)! if you still use hibernate 3 as JPA provider in your application and you want to deploy it in Jboss AS7 ... you may know it's possible ... Humm yes you can do it just by creating a module for hibernate3 under your Jboss AS7 (how powerful server is !). So you just need to:

* Create a folder in AS7_HOME\modules\org\hibernate\3 for slot 3 to hold your hibernate 3 jars.

* Copy the hibernate 3 associated jars into this folder. For example:

•antlr-3.2.jar
•asm-3.3.jar
•btm-1.3.3.jar
•hibernate-commons-annotations-3.2.0.Final.jar
•hibernate-core-3.6.1.Final.jar
•hibernate-entitymanager-3.6.1.Final.jar

* Create the AS7_HOME/modules/org/hibernate/3/module.xml file with contents :































That's it, your module now is available on your jboss 7 server, all you nedd to link it with your application is to add the followed property to your persistence unit :

Note the org.hibernate:3 on your jboss.as.jpa.providerModule property ;-)

2 comments:

  1. Cool, nice to know. But how do you generate the dependencies-tag in the module.xml? I want to add other module ^^

    Thanks

    ReplyDelete
  2. There is a cyclic reference on hibernate slot number in module "org.jboss.as.jpa.hibernate".

    ReplyDelete