Maven Hibernate 4.0.1 pom.xml - Dependencies

I have been avoiding using Hibernate for a while now. I have been using alternatives such as the reference implementation, eclipselink or Apache's openjpa. But I have to keep up to date with Hibernate for our JBoss training sessions, where the more developer focused training sessions, often cover examples of hibernate with JBoss for EJBs. If you are using JBoss then its safe to just use the contents of the <jboss-home>/clients directory and know its compatible with the version of JBoss you are running. If you using maven then check them into your local repo. You can also use the JBoss repo.

   <repository>
        <id>JBoss</id>
        <name>JBoss Repsitory</name>
        <layout>default</layout>
        <url>http://repository.jboss.org/maven2</url>
    </repository>

JBoss and Hibernate

If you prefer a more light-weight approach to using hibernate and like maven then getting compatible version for the various libraries in the pom.xml can be a little tricky. Here is the pom.xml extract for Hibernate 4.0.1 release. Note this is for Hibernate only. If you pull in the -all dependency you will end up with JGroup and Infiband jars which are for multicating and cluser management. Not needed by most developers.

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>        
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>4.0.1.Final</version>
            <classifier>tests</classifier>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>      
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.0.1.Final</version>
        </dependency>       
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.1.0.CR2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.4</version>
        </dependency>
       

Logging and Hibernate 4.0.1

Hibernate makes use of the simple logging framework for Java (slf4j) and jboss-logging to allow you to use your favourite logging backend. You can leave out the last 3 dependencies if you don't want logging or just change the last entry to use the appropriate jar for your logging backend.
 

Comments

Thanks Mark, you make my day again!
I looked all over and can't seem to find any other good reference for this..

Glass Curtains Marbella
The deployment type you mentioned is quite interesting. While using the codes, I always lack sufficient confidence. But when it comes to rewriting the algorithm, I do it well. I am totally gonna purchase this application. Great post folks!