One of the more frequent questions about jOOQ is how to write a derived table (or a CTE). The jOOQ manual shows a simple example of a derived table: In SQL: SELECT nested.* FROM ( SELECT AUTHOR_ID, count(*) books FROM BOOK GROUP BY AUTHOR_ID ) nested ORDER BY nested.books DESC In jOOQ: // Declare the … Continue reading How to Write a Derived Table in jOOQ
Tag: Type safety
Why You Should Execute jOOQ Queries With jOOQ
Previously on this blog, I've written a post explaining why you should use jOOQ's code generator, despite the possibility of using jOOQ without it. In a similar fashion, as I've answered numerous jOOQ questions on Stack Overflow, where someone used jOOQ to build a query, but then executed it elsewhere, including on: JPA JDBC / … Continue reading Why You Should Execute jOOQ Queries With jOOQ
Projecting Type Safe Nested TableRecords with jOOQ 3.17
A long standing feature request has seen little love from the jOOQ community, despite a lot of people probably wanting it. It goes by the unimpressive title Let Table<R> extend SelectField<R>: https://github.com/jOOQ/jOOQ/issues/4727 What does the feature mean, specifically? The awesome PostgreSQL Let's have a look at a really cool PostgreSQL feature. In PostgreSQL, it is … Continue reading Projecting Type Safe Nested TableRecords with jOOQ 3.17
Why You Should Use jOOQ With Code Generation
I'm answering many jOOQ questions on Stack Overflow, and a lot of times. The problem has the same cause: People not using jOOQ's code generator. The main reason people seem not to be using it, is because it takes some extra time to set up, but as with anything well designed, the initial investment will … Continue reading Why You Should Use jOOQ With Code Generation
What’s a “String” in the jOOQ API?
One of jOOQ's biggest strength is the fact that it is a type safe SQL API. "Type safe", in this context, means that every object that you put in a jOOQ query has a well defined type, such as: Condition Field Table These can be used in jOOQ in a type safe way as such: … Continue reading What’s a “String” in the jOOQ API?
This Common API Technique is Actually an Anti-Pattern
I admit, we've been lured into using this technique as well. It's just so convenient, as it allows for avoiding a seemingly unnecessary cast. It's the following technique here: interface SomeWrapper { <T> T get(); } Now you can type safely assign anything from the wrapper to any type: SomeWrapper wrapper = ... // Obviously … Continue reading This Common API Technique is Actually an Anti-Pattern