~/devreads

#collector

5 posts

24 Mar 2023

19 May 2022

lukaseder 1 min read

The jOOQ API is all about convenience, and as such, an important operation (the most important one?) like fetch() must come with convenience, too. The default way to fetch data is this: It fetches the entire result set into memory and closes the underlying JDBC resources eagerly. But what other options do we have? Iterable … Continue reading The Many…

joojooq-in-usecollectorconveniencejava

9 Dec 2021

lukaseder 1 min read

In classic SQL (i.e. before jOOQ’s awesome MULTISET operator), nested collections were fetched using ordinary (outer) joins. An example of such a query would be a query running against the sakila database to fetch actors and their films. Using jOOQ: The result from the jOOQ debug log would look something like this: +--------+----------+---------+-------+---------------------+ |actor_id|first_name|last_name|film_id|title | … Continue reading Using JDK…

jooq-in-usecollectorjdk collectorsjooqleft join

17 May 2021

lukaseder 1 min read

In our opinion, any Iterable<T> should offer a <R> collect(Collector<T, ?, R>) method to allow for transforming the the content to something else using standard JDK collectors, jOOλ collectors from org.jooq.lambda.Agg or your own. When using jOOQ, you don’t have to wait for the JDK to finally add these useful utilities to the Iterable API. … Continue reading Use ResultQuery.collect()…

jooq-in-usecollectorcollectorsgroupingjava

9 Oct 2018

lukaseder 1 min read

All SQL databases support the standard aggregate functions COUNT(), SUM(), AVG(), MIN(), MAX(). Some databases support other aggregate functions, like: EVERY() STDDEV_POP() STDDEV_SAMP() VAR_POP() VAR_SAMP() ARRAY_AGG() STRING_AGG() But what if you want to roll your own? Java 8 Stream Collector When using Java 8 streams, we can easily roll our own aggregate function (i.e. a … Continue reading Writing Custom…

java 8sqlaggregate functionaggregate functionscollector