JPA 2.0 migration experience

Java EE 6 specification released not so long ago, and now includes release of JPA 2.0 specification. Obviously, you'd like to use JPA 2.0 for your new project. But the problem is, how to choose good implementation and where to get it?

First you will go to Sun's persistance page. You'll read a bit and click on "download" link that will take you on Glassfish Persistance page. But the problem is, you will not find JPA 2.0 reference implementations on that page.

Ok, next step - ask google. Google sais that EclipseLink is reference implementation for JPA 2.0, and wikipedia confirms. Let's go to EclipseLink downloads. Yea, there are some files to download, but again everything is packed into single huge JAR with dozens of features we don't really need (yea, I have "classpath paranoia"), and the main component is missing - sources for JPA 2.0 API, that can be added to NetBeans libraries to read javadocs and to help it with method argument names (do you remember that Library Manager in NetBeans?).

We must not give up. Let's go to JSR page and take a look. Wikipedia states it's JSR 317. After clicking on "Download" link we can see another link, that will direct us to "EclipseLink's Reference Implementation Downloads". After downloading both and taking a look inside of each package we can see that "EclipseLink 2.0.0 - minimal bundles that are shipped in the Java EE6 RI" is what we really need. Finally, everything we may need and packed in separate small JARs, so we can include only features we need.

Now, let's make it work. I have project that used JPA 1 with EclipseLink 1.2.0. I removed all EclipseLink libraries, added javax.persistence_2.0.0.v200911271158.jar (JPA 2.0 API) and org.eclipse.persistence.jpa_2.0.0.v20091127-r5931.jar (one that contains org.eclipse.persistence.jpa.PersistenceProvider). First few starts of application ClassNotFound were reported, I searched for required classes and added their JARs. Finally, here is the full list of JARs you need to work with standard JPA 2.0 feature set:

and files to add to Sources tab (NetBeans will be able to show you sources, javadocs and read method argument names from those sources):

That's all. Use JPA 2.0 with pleasure, support new versions and software evolution, because otherwise we all will become stupid monkeys and will return back on palms.

1 comment:

Doug said...

I updated the EclipseLink 2.0.0 release notes to include a downloads link to the JPA 2.0 RI.