Java Persistence API (JPA) - OSGi-Compatible Version Print E-mail

The main problem with JPA APIs is that they look for the JPA Service provider (Toplink, OpenJPA and Hibernate), Database driver (MySQL, H2, HSQLDB, Derby, etc.) and User's Entity classes in thread context class loader which is not suitable for OSGi-based applications. The Provided API looks for JPA Service Providers, Database drivers and Entity classes in the OSGi Environment even if the packages that contain these classes are not imported by the JPA API bundle.

OSGi Compatible JPA API: org.dynamicjava.jpa-api-1.0.jar

OSGi Compatible JPA API Source Code: org.dynamicjava.jpa-api-1.0-src.zip

Original API's Source Code was taken from: Geronimo Specs

Test Application

The archive jpa-api-test.zip contains an OSGi-based test application which has two test bundles that use JPA API, one of them has a Persistence Unit that uses Toplink with H2 Database, the other OpenJPA with HSQLDB. Alongside the JPA API bundle provided by DynamicJava.org there are the JPA API class library provided with the Reference Implementation. The aim of this application not only to highlight the difference in the behavior between these different versions of the JPA API modules when run in an OSGi Environment but also to prove that the JPA API provided by DynamicJava.org is runnable with the OSGi Frameworks Felix and Equinox in Java Environments JRE and JDK versions 1.5 and 1.6 - unlike other versions of the JPA API.

Notes on Current Release of the Provided API

  • If you have multiple versions of the packages that contain your Entity classes, you might have problems since there is no guarantee of the version JPA API will load. Next version will add a mechanism to support such cases.
  • Current version doesn't support Knopflerfish. Support for Knopflerfish will mostly be added in the next release.