Java data access technology survey results

Imagine having a tool that can automatically detect JPA and Hibernate performance issues. Wouldn’t that be just awesome?

Well, Hypersistence Optimizer is that tool! And it works with Spring Boot, Spring Framework, Jakarta EE, Java EE, Quarkus, or Play Framework.

So, enjoy spending your time on the things you love rather than fixing performance issues in your production system on a Saturday night!

Introduction

Java has tons of data access frameworks, and in this article, we are going to what Java database technology is preferred by developers and for what reasons.

The number one reason why we have so many data access frameworks in Java is JDBC. JDBC was a remarkable achievement. Prior to JDBC, programming languages didn’t have a database communication abstraction that could allow one application to work with any relational database implementing the JDBC Driver specification.

The fact that JDBC offered this unified abstraction allowed Java developers to create various data access frameworks, each one with its own approach to reading and writing data.

And another reason for having so many data access frameworks is because the JDBC API is awful to use. Even if it’s amazingly useful from a database portability point of view, in reality, no developer dreams of writing JDBC code. Luckily, they don’t even have to, as Java has a huge ecosystem of frameworks at our disposal.

The poll

As much as I’d like to run such a pool, it would not be a good idea if I did it because my audience is skewed in JPA and Hibernate’s favor.

That’s why I was very happy yesterday when the amazing Josh Long ran this poll for us:

Not only does Josh has a huge follower base, but his audience is not associated with one particular data access technology. In fact, due to the huge Spring Boot popularity, he can better capture real-world data access usage since you can use Spring with JPA, JdbcTemplate, QueryDSL, Spring Data JDBC, MyBatis, or jOOQ.

The 2022 results

No surprise here!

Java data access technology preference

JPA and Hibernate

Since I started using NHibernate in 2004, Hibernate and later JPA have been the number one choice for the vast majority of Java projects that have to interact with a relational database.

As I explained in this article, the reasons why JPA and Hibernate are so immensely popular are because of convenience and abundance of resources.

Spring Data JPA

Undeniably, JPA and Hibernate thrived due to their tight integration with Spring. The more popular Spring became, the more people used Spring Data JPA, and the more Hibernate was used since this is the default JPA implementation Spring uses.

While the Spring framework provides declarative transaction handling, Spring Data JPA solves the DAO (Data Access Object) layer problem since it can provide default implementations for entity repositories.

After using Spring Boot and Spring Data JPA, it’s hard to go back because Spring made it so easy to use it.

Resource abundance

Another reason why JPA is so popular is the massive resource base. There are hundreds of books, tens of thousands of articles, and hundreds of thousands of StackOverflow answers ready to help you with any possible issue you’d ever have.

When choosing a technology, there are two types of unknowns you will bump into:

  • known unknowns
  • unknown unknowns

The former is just the things you don’t know yet, but others have figured out and documented thoroughly.
The latter is what no one got the chance to figure out because the technology might be too new or just unpopular.

The more mature the technologies you are using, the more resources you’ll have at your disposal to get the best out of it.

Whatever issue you might have with JPA and Hibernate, there’s a solution for it. If you don’t believe me, just scroll down my JPA and Hibernate tutorial page, and you’ll see what I meant.

Spring JdbcTemplate

When Spring developers have modest data access requirements, they favor Spring JdbcTemplate.

Been there, done that! The JdbcTemplate is fine when your entire data access logic reduces to just a few statements. The JdbcTemplate is a much better alternative to plain JDBC because it provides the RowMapper abstraction, and it provides a NamedParameterJdbcTemplate extension in case you want to use named parameters in your SQL statements.

MyBatis

MyBatis is very popular in China. I don’t know why, but this is a fact.

MyBatis is an advanced version of JdbcTemplate, but it has some weird limitations. For instance, I had to do some consulting work for a company that used the Activity business automation framework, which in turn uses MyBatis. While investigating ways to improve performance, I realized MyBatis does not even support PreparedStatement batching, which is a basic requirement for a non-trivial data access layer. Even JdbcTemplate has that.

jOOQ

Lukas Eder did a great job with jOOQ. Currently, if you need to build SQL queries dynamically, jOOQ is the best choice. However, you can use jOOQ to implement your entire data access logic.

Unlike other frameworks, jOOQ provides a type-safe API that you can use to build very complex SQL queries. If you have great SQL skills, you are going to love jOOQ. Unfortunately, advanced SQL knowledge is very rare among application developers. For some reason, SQL doesn’t click with many developers, and, in turn, they do anything possible to avoid it even if it means fetching the entire database in a single SQL query just to process it with Java Streams.

I wrote about jOOQ in my High-Performance Java Persistence book because Hibernate and jOOQ are the most powerful Java data access frameworks. The more you know about these two frameworks, the more you’ll be able to solve any possible data access requirement.

The 2019 results

What’s great about Josh’s poll is that he also ran it in 2019.

The results are very similar, so nothing has really changed over the past 3 years.

I'm running an online workshop on the 11th of October about High-Performance SQL.

If you enjoyed this article, I bet you are going to love my Book and Video Courses as well.

Conclusion

Java has plenty of data access frameworks, which is awesome from a Java developer perspective because you can choose the best tool that fits your current job.

While JPA and Hibernate are still the most popular Java data access technologies, there are many other great frameworks that are worth using, like jOOQ. I’ve seen developers praising Jdbi and sql2o too. I haven’t used those, but I’m glad there are many alternatives because competition drives innovation.

Transactions and Concurrency Control eBook

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.