What jar should I include to use javax.persistence package in a hibernate based application?

Is it ok to take it from Glassfish project ( glassfish-persistence-api) or may be there is a Hibernate jar?


Solution 1:

If you are using maven, adding below dependency should work

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0</version>
</dependency>

Solution 2:

If you are developing an OSGi system I would recommend you to download the "bundlefied" version from Springsource Enterprise Bundle Repository.

Otherwise its ok to use a regular jar-file containing the javax.persistence package

Solution 3:

You can use the ejb3-persistence.jar that's bundled with hibernate. This jar only includes the javax.persistence package.