Abstract query
select A.*, B.*, C.*
from A
left join B on B.aId = A.aId
left join C on C.cId = B.cId
Idea
I want to fetch this into some object, which is grouped by A (each B has a unique C connected to it). For me the most logical type of object to fetch into, would be something like Map<A, List<Record2<B,C>>.
Code
I tried something like
using(configuration()).select(A.fields())
.select(B.fields())
.select(C.fields())
.from(A)
.leftJoin(B).on(B.aId.eq(A.aId)
.leftJoin(C).on(C.cId.eq(B.cId)
.fetchGroups(
r -> r.into(A).into(APojo.class),
r -> r.into(B).into(BPojo.class),
r -> r.into(C).into(CPojo.class)); // Goes wrong because fetchGroups only accepts 2 arguments
Background of solution
I don't want to use fetch(), because all the records would contain duplicate data of A, which I want to avoid. I am converting it to a JSON object, where A would contain a list of B's and in which B contains the object C. To get this structure, Map<A, List<Result2<B,C>> would be perfect.