Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find a JPA2 Maven dependency?

I'm trying to build an implementation agnostic maven module which relies on JPA2. Unfortunately, the only Maven JPA dependency is JPA1 based, and consequently, I cannot use EntityManager.detach() method as that is a JPA2 option only.

Ideally, I'd love to be able to specify my javax.persistence dependency in my Pom, and require the app/container to supply the JPA2 implementation. Unfortunately, I cannot find any such dependency.

Is my only choice at this point to declare hibernate-jpa-2.0-api 1.0.0.FINAL as a provided dependency?

like image 715
Eric B. Avatar asked Jul 26 '11 21:07

Eric B.


People also ask

Where can I find Maven dependencies?

In your project's POM, press Ctrl and hover the mouse over the dependency. Click the dependency to open the dependency's POM. In the dependency POM, view the active dependency, its transitive dependencies and their versions. You can check the origin from which the dependency was pulled in.

How Maven dependencies are downloaded and stored?

When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build. Maven local repository by default get created by Maven in %USER_HOME% directory.

What are the Maven dependencies?

There are two types of dependencies in Maven: direct and transitive. Direct dependencies are the ones that we explicitly include in the project. On the other hand, transitive dependencies are required by direct dependencies. Maven automatically includes required transitive dependencies in our project.


1 Answers

I know this is a quite old post, if you want to go agnostic from the implementation, then you should use the Java EE API dependency instead.

Just add to your POM:

<dependency>     <groupId>javax</groupId>     <artifactId>javaee-api</artifactId>     <version>${jee.version}</version>     <scope>provided</scope> </dependency> 

Where the ${jee.version} is your desired Java EE version. I'm currently using 7.0. It has all EJB, JPA and JSF APIs dependencies.

like image 94
ramsvidor Avatar answered Oct 03 '22 05:10

ramsvidor