Friday, December 26, 2008

Using JPA and Hibernate with Maven

I have been fighting a bit to set up a Maven project with JPA and Hibernate as persistence provider.

The final solution is very simple. But when you get on a wrong track at the beginning, you end up in a terrible maze...

So here the most important hint:
The JBoss repository ( is quite a mess.
In the root of the repository you find directories (matching Maven GroupIds) for hibernate , hibernate-annotations and hibernate-entitymanager.
Do not use them!
They are outdated, do not provide current versions and most annoying do not declare their dependencies... so your pom will get a mess.

All dependencies should use the GroupId org.hibernate (browse into the org directory in the Maven repository).

So here is my working pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">





  1. Jonas, thanks - you have probably saved a lot of people hours and hours of wasted time. I feel that Maven lacks a deprecation mechanism that would make it obvious to everyone that they're using something out of date. The problem is that once an artifact has been published it is never supposed to change thereafter. But it shouldn't be impossible to devise a mechanism for adding deprecation and redirection to the associated metadata.

  2. I think this is so important that I've made a reference to it in a new Maven issue - see

  3. I'm pleased to say that Brett Porter has scheduled my suggested Maven improvement for Release 3.

  4. Yes thank you very very much !!

    I fight a day to found your solution !


Related Posts Plugin for WordPress, Blogger...