Apache OpenJPA – Life beyond hibernation?

Apache OpenJPA is the Apache Software Foundation‘s Java persistence project. After flying under the radar for some time, there’s a new release. Let’s take a look.


JPA, also known as Java Persistence API, manages persistence and object-relational mapping in Java EE and Java SE environments. Libraries like OpenJPA, Hibernate or EclipseLink are the ones that provide the implementations of the standard.

By writing code that adheres to the API, you are not limited by the functionality of the specific library, although sometimes the additional non-standard functionality they provide can be desirable. Therefore, you can always swap out these libraries behind the scenes to improve performance, reduce bugs, or avoid edge cases. For this reason, it’s a good idea to avoid using implementation-specific constructs like the Hibernate.initialize instance to initialize a proxy for lazy fetching, or using user-defined datatypes and Hibernate-specific annotations like @NaturalKey. If you want to be omnipresent, you have to stay close to the standard.

Since Spring is the most popular Java method for accessing the database via JPA, the question naturally arises as to whether Spring Data JPA is supported by Apache Open JPA. The answer is yes, but other libraries like Hibernate have swept the market since development of Open JPA has been very slow for the last few years, forcing the Spring Data team to remove it from the JPA implementations it tests against.

Libraries also differ based on which version of the protocol they cover. Since the renaming of the Java Persistence API (JPA) to the Jakarta Persistence API, the waters have become murkier in this regard, since after Oracle opened source Java EE, the rights passed to the Eclipse Foundation, which had to change the name for copyright reasons. see Eclipse renames Java EE specifications to Jakarta EE. So in 2019 JPA was renamed Jakarta Persistence and the first release with that name was version 3.0 in 2020. This involved renaming packages and properties from javax.persistence to jakarta.persistence. As such, the latest Spring Boot starters use it jakarta.persistence-api instead of the Javax.persistence-api.

The latest OpenJPA version 3.2.2 was released this March and covers Javax 2.2, whose specifications were published under JSR 338 in 2017. For comparison, Hibernate 5.3.0, released in 2018, already covered them, so OpenJPA is 4 years behind in respect. Hibernate from version 5.5 covers Jakarta Persistence v3.0.

The OpenJPA version 3.2.2 release notes are sparse, containing only the following changes:

Added support for Java8 Date/Time types
javax.xml.bind needs to be moved to the Jakarta namespace

To answer the question about life beyond Hibernate, I certainly wouldn’t answer in light of OpenJPA. It’s not about the legacy standard it supports – conforming to the full spectrum of a standard isn’t easy.

Take the popular DBMS Postgres for example. PostgreSQL supports most of the core features of Core SQL:2016. Out of 177 mandatory features required for full core compliance, PostgreSQL conforms to at least 170. In addition, a long list of optional features is supported. And in his defence:

It might be worth noting that at the time of writing, no current version of any database management system claims full compliance with Core SQL:2016.

Likewise, many who use Spring Data JPA and Hibernate may not be using the full spectrum of JPA 3.0, but are still working with the features of 2.2.

What else is there to say? Apart from the project’s good documentation on the JPA standard, the only ones I see happy about the new release are those already using it in production. A search found it:

187 Companies using Apache OpenJPA, most commonly found in the United States and in the computer software industry. Apache OpenJPA is most commonly used by companies with >10000 employees and >1000 million dollars in revenue.

Pretty big companies if you ask me. Considering industries of this size are reluctant to modernize, OpenJPA still has value.

openjpa-logosq

More information

Apache OpenJPA 3.2.2 Release Notes

The Apache OpenJPA project

Companies using Apache OpenJPA

On the subject of matching items

Hibernate going reactive – what does that mean?

Eclipse renames Java EE specifications to Jakarta EE

To be notified of new articles on I Programmer, sign up for our weekly newsletter, Subscribe to the RSS feed and follow us Twitter, Facebook or linkedin.

banner


python data



Remarks

or email your comment to: [email protected]

Comments are closed.