+

Search Tips   |   Advanced Search

Java Persistence API 2.1 behavior changes

If our existing applications are using the built-in JPA 2.0 persistence provider, OpenJPA or WSJPA, we 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. We cannot use both the built-in EclipseLink provider and OpenJPA/WSJPA provider within the same server. To change our existing applications to use the JPA 2.1 persistence provider, EclipseLink, we might need to adjust the application.


Differences between EclipseLink and OpenJPA/WSJPA

There are a few major differences between EclipseLink and OpenJPA/WSJPA needed 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. We must ensure that this setting is the best option for the applications. If we are running in a distributed environment, like a cluster, we need to disable the cache, or understand that different nodes can have different data.

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

Enhancement / weaving differences

EclipseLink: EclipseLink works with unenhanced entities. WAS 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 we 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 we use this feature.

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

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