Search code examples
hibernatemavenjpajbossjava-ee-5

Do I need Hibernate-JPA 2.0 dependency in pom.xml for JBOSS 5 container?


In one of the modules that we use, it has only Entities and this is used across different modules, the dependency for hibernate in Entities module is declared in pom.xml as follows:

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
</dependency>

what does this mean?

I thought we are using JPA 2.0 API and the underlying implementation is hibernate V1.0.1.

My colleague said we have this dependency for compile time scope because JBOSS AS 5 (which is our application server) provides the hibernate dependency (which is version > 3.4 I guess).

The question I had is why in the above dependency 1.0.1 and not that of JBOSS's hibernate version. my colleague said it does not matter. But I don't understand why? I am sure JPA2.0 API will not be compatiable with hibernate 1.0.1. so am I really using JPA 2.0?


Solution

  • This is the version 1.0.1 of JPA 2.0. The version 1.0.1 is the JAR version, not what the code implements.

    It is JPA 2 (code) with jar version 1.0.1.

    ------- Update 1

    If you do not send any implementation you will be using JPA 1. I found this: https://access.redhat.com/articles/112673 that says that JBoss EAP 5 uses JPA 1.

    If you send only the API you will use the current JPA implementation of the server.