How to fetch multiple to-many relationships with jOOQ MULTISET

Introduction In this article, we are going to see how we can fetch multiple to-many relationships with jOOQ MULTISET so that we avoid bumping into an unintentional Cartesian Product. The approach taken by jOOQ is truly revolutionary since it offers a solution that allows you to fetch multiple to-many relationships using a single type-safe query.

Cache synchronization using jOOQ and PostgreSQL functions

Introduction In this article, we are going to see how we can achieve cache synchronization with the help of jOOQ and PostgreSQL functions. By using Change Data Capture, we can track how table records change over time and synchronize the application-level cache entries that were built from the table records in question.

The best way to call SQL Server stored procedures with jOOQ

Introduction In this article, we are going to see what is the best way to call SQL Server stored procedures with jOOQ. I decided to write this article because stored procedures and database functions are extremely useful for data-intensive applications, and sometimes, they are the only solution to process data efficiently. While SQL remains the de-facto way to query data, when it comes to processing records, stored procedures allow us to control the transaction boundaries so that we can release the locks acquired for the modified records sooner and make sure that… Read More

Java data access technology survey results

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… Read More

The data knowledge stack

Concurrency is not for the faint-hearted We all know concurrency programming is difficult to get it right. That’s why threading tasks are followed by extensive design and code review sessions. You never assign concurrent issues to inexperienced developers. The problem space is carefully analyzed, a design emerges and the solution is both documented and reviewed. That’s how threading related tasks are usually addressed. You will naturally choose a higher level abstraction since you don’t want to get tangled up in low-level details. That’s why the java.util.concurrent is usually better (unless you build… Read More

JOOQ Facts: SQL functions made easy

Introduction The JDBC API has always been cumbersome and error-prone and I’ve never been too fond of using it. The first major improvement was brought by the Spring JDBC framework which simply revitalized the JDBC usage with its JdbcTemplate or the SqlFunction classes, to name a few. But Spring JDBC doesn’t address the shortcoming of using string function or input parameters names and this opened the door for type-safe SQL wrappers such as jOOQ. JOOQ is the next major step towards a better JDBC API and ever since I started using it… Read More

JPA Criteria API can generate unexpected SQL statements

Introduction In this article, we are going to learn why you should always check the SQL statements generated by JPA Criteria API queries when using Hibernate. Criteria API is very useful for dynamically building queries, but that’s the only use case where I’d use it. Whenever you have a UI with N filters that may arrive in any M combinations, it makes sense to have an API to construct queries dynamically since concatenating strings is always a path I’m running away from. The question is, are you aware of the SQL queries… Read More

JOOQ Facts: From JPA Annotations to JOOQ Table Mappings

JOOQ is a neat framework, and it addresses a long-time issue I’ve had with advanced dynamic filtered queries. While Hibernate and JPA come with a useful Criteria API, which I’ve been using for quite some time, there are understandable limits to what you can do with those. For instance, you cannot go beyond simple SQL operations (e.g JOINS, NESTED SLECTS, AGGREGATION) and do something like: window functions, user-defined functions or easy sequencing to name a few. JOOQ doesn’t feel like competing with Hibernate, but instead, I feel like it completes it. I’ve… Read More