Jooq fetchInto with default value if field is null

The reason is that JSON_ARRAYAGG() (like most aggregate functions) produces NULL for empty sets, instead of a more “reasonable” empty []. Clearly, you never want this behaviour. So, you could use COALESCE, instead, see also this question: coalesce( jsonArrayAgg(jsonObject(book.ID, book.PRICE)), jsonArray() ) I’ll make sure to update all the other answers I’ve given on Stack … Read more

java.util.stream with ResultSet

The first thing you have to understand is that code like try (Connection connection = dataSource.getConnection()) { … try (PreparedStatement pSt = connection.prepareStatement(sql)) { … return stream; } } does not work as by the time you leave the try blocks, the resources are closed while the processing of the Stream hasn’t even started. The … Read more