Java™ Persistence API 2.1 behavior changes

If your existing applications are using the built-in JPA 2.0 persistence provider, OpenJPA or WSJPA, you can continue using the same provider to avoid migration issues. For new applications, use the built-in JPA 2.1 persistence provider, EclipseLink, to take advantage of the new features available in the JPA 2.1 specification. A server can be configured for the JPA 2.1 specification level or the JPA 2.0 specification level, which determines which built-in JPA persistence providers are available. You cannot use both the built-in EclipseLink provider and OpenJPA/WSJPA provider within the same server. If you want to change your existing applications to use the JPA 2.1 persistence provider, EclipseLink, you might need to adjust your application.

Differences between EclipseLink and OpenJPA/WSJPA

There are a few major differences between EclipseLink and OpenJPA/WSJPA that you need to be aware of:

PersistenceProvider class name
EclipseLink provider class
  • EclipseLink: org.eclipse.persistence.jpa.PersistenceProvider
OpenJPA/WSJPA provider class
  • OpenJPA: org.apache.openjpa.persistence.PersistenceProviderImpl
  • WSJPA: com.ibm.websphere.persistence.PersistenceProviderImpl
Caching behavior

EclipseLink: By default, the EclipseLink provider has the L2 cache and QueryCache enabled. You must ensure that this setting is the best option for your applications. If you are running in a distributed environment, like a cluster, you need to disable the cache, or understand that different nodes can have different data.

OpenJPA/WSJPA : Caching is disabled by default. If your application needs to take advantage of a L2 cache, you must explicitly enable it.

Enhancement / weaving differences

EclipseLink: EclipseLink works with unenhanced entities. WebSphere Application Server supports static enhancement.

OpenJPA/WSJPA: OpenJPA requires entities to be enhanced. See the documentation on the enhancement of JPA entities for more information.

  • If entities classes are statically enhanced for use with the OpenJPA/WSJPA provider, the classes must be recompiled before you use the EclipseLink provider.
Data source usage differences

EclipseLink uses a non-jta-datasource connection when reading data and a transaction is not active. This means that non-jta-datasource connection pools need to be larger when you use this feature.

OpenJPA/WSJPA sparingly uses the non-jta-datasource, so few non-jta-datasource connections are required when you are tuning an application.

See the OpenJPA -> EclipseLink migration guide page for more differences between the two JPA providers.