jOOQ can I fetch a join of two tables into the respective POJOs

Using nested collections With more recent versions of jOOQ, you’ll typically use a set of ORDBMS features, including: nested collections using MULTISET nested records and nested table records ad-hoc converters You’ll write something like this, to produce jOOQ types: Result<Record2<UserRecord, Result<Record1<RoleRecord>>>> result = dsl.select( USER, multiset( selectFrom(USER_ROLE.role()) .where(USER_ROLE.USER_ID.eq(USER.ID)) )) .from(USER) .where(USER.U_EMAIL.equal(email)) .fetch(); Or, by using … Read more

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