Apache OpenJPA - Life Beyond Hibernate? |
Written by Nikos Vaggalis |
Tuesday, 24 May 2022 |
Apache OpenJPA is the Java persistence project of the Apache Software Foundation. After quite some time flying under the radar, there's a new release. Let's look into it. JPA, aka the Java Persistence API, manages persistence and object relational mapping in Java EE and Java SE environments. Libraries like OpenJPA, Hibernate or EclipseLink are those providing the implementations of the standard. By writing code that adheres to the API you are not constrained by the specific library's features, despite the fact that sometimes the additional non-standard functionalities they provide can be desirable. Therefore you are free at any time to swap those libraries behind the scenes for improved performance, reduction in bug count or edge cases. That's why it is advisable not to use implementation-specific constructs such as instance Hibernate.initialize for initializing a proxy for lazy fetching, or custom data types and Hibernate-specific annotations like @NaturalKey. If you want to be ubiquitous you must stay close to the standard. Since Spring is the most popular Java way of accessing the database through JPA, the question is, of course, whether Spring Data JPA is supported by Apache Open JPA.The answer is yes, but other libraries like Hibernate have overrun the market since the development of Open JPA was very slow in recent years, forcing the Spring Data Team to drop it from the JPA implementations it tests against. Libraries also differentiate by which version of the protocol they cover. Waters have become murkier in this respect since the Java Persistence API (JPA) was renamed Jakarta Persistence API because, after Java EE was open sourced by Oracle, the rights were transferred to the Eclipse Foundation which had to change the naming because of copyright reasons, see Eclipse Renames Java EE Specifications to Jakarta EE. So JPA was renamed Jakarta Persistence in 2019 and the first release with that name was version 3.0 in 2020. This included the renaming of packages and properties from javax.persistence to jakarta.persistence. As such the latest Spring Boot starters use 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 released in 2017 under JSR 338. For comparison, Hibernate 5.3.0, released in 2018, already covered them, so OpenJPA is 4 years behind in that respect. Hibernate from version 5.5 on covers Jakarta Persistence v3.0. The Release Notes of OpenJPA version 3.2.2 are slim, containing only the following changes: Add support for Java8 Date/Time types To answer the question of life beyond Hibernate, I would answer certainly not in light of OpenJPA. It's not about the old standard that it supports - compliance to the full spectrum of a standard is not something easy to do. Take for example the popular DBMS, Postgres. PostgreSQL supports most of the major features of Core SQL:2016. Out of 177 mandatory features required for full Core conformance, PostgreSQL conforms to at least 170. In addition, long list of optional features are supported. And in its defence: It might be worth noting that at the time of writing, no current version of any database management system claims full conformance to Core SQL:2016. Similarly many who use Spring Data JPA and Hibernate might not be leveraging the full spectrum of JPA 3.0, but still work with features of 2.2. So what else is there to say? Apart from the good documentation of the project on the JPA standard, the only ones I see happy because of the new release are those who are already using it in production. A search revealed that there are: 187 companies that use Apache OpenJPA, most often found in United States and in the Computer Software industry. Apache OpenJPA is most often used by companies with >10000 employees and >1000M dollars in revenue. Pretty big corporations if you ask me.Considering that industries of such size are reluctant to modernize, there's still value in OpenJPA. More InformationRelease Notes for Apache OpenJPA 3.2.2 Companies using Apache OpenJPA Related ArticlesHibernate goes Reactive - What Does That Mean? Eclipse Renames Java EE Specifications to Jakarta EE
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Tuesday, 24 May 2022 ) |