Using jOOQ With Spring

I have had my share of performance problems caused by ORM tools, and if you have used them, you must know what I am talking about. Two most common performance problems caused by ORM tools are:

  1. The N + 1 selects problem
  2. Selecting partial objects is hard which ensures that index-only scans are never done.

At some point I decided to eliminate some of these problems by making one simple decision: I stopped using an ORM tool for read-only operations. When I was looking for alternative way to implement read-only queries, I ran into jOOQ.

jOOQ is a library which helps you to get back in control of your SQL. It can generate code from your database and lets you build typesafe database queries by using its fluent API.

jOOQ helps you to solve the performance problems caused by ORM tools because you (and not the ORM tool) decide what kind of SQL queries your applications executes against its database.

You can of course solve these problems by using JDBC but this creates few new problems:

  1. Writing SQL queries manually is time consuming.
  2. Writing SQL queries manually is error prone because errors are detected at run time.
  3. Writing SQL queries manually creates a vendor lock-in.

jOOQ solves every one of these problems!

Are you excited? I though so.

Introducing: Using jOOQ With Spring

This five part tutorial will help you get started with jOOQ and it consists of the following blog posts:

If enjoyed reading this tutorial, you might want to take a look at my Spring Data book.

Other Resources

This section showcases useful material created by other developers. If you have written a blog post or recorded a video about jOOQ, and want to include it to this section, ping me on Twitter and I will check it out. If I think that it is useful, I will add it to this section.

  • jOOQ – Type safe DB querying on JCG Academy. This FREE course has a five star rating, and it is written by Lukas Eder (The creator of jOOQ). Check it out!