Building maven-hibernate-plugin for Hibernate v2.x and v3.x

by Jim Alateras

The latest version of the maven-hibernate-plugin only supports Hibernate v2.x and cannot be used for projects that depend on Hibernate v3.x. Fortunately, there is a patch you can apply to v1.3 of the maven-hibernate-plugin to support both Hibernate v2.x and v3.x.

This short article provides a step-by-step guide for applying the patch and installing the new plugin, version 1.4.

  1. Have a look at theJIRA Entry, which talks about Support for Hibernate 3.0

  2. Download the patch.

  3. Download the v1.3 of the maven-hibernate-plugin using svn
    svn checkout

  4. Download the plugin-parent directory, since this is referenced by the maven-hibernate-plugin using svn svn checkout

  5. Change into the \MAVEN_HIBERNATE_1_3 directory and apply the patch by executing
    patch -p0 < version2and3comat.diff .

  6. Build and install the plugin maven plugin:install

And that's all there is to it. Alternatively you can skip steps 1-6, download maven-hibernate-plugin-1.4.jar and drop it in MAVEN_HOME/plugins directory......but where's the fun in that ;-).