Fetching groups
The jOOQ fetching groups feature is similar to fetching maps, except that it allows us to fetch a list of records as the value of each key-value pair. There are over 40 flavors of the fetchGroups()
, intoGroups()
, and intoResultGroup()
methods; therefore, take your time to practice (or, at the very least, read about) each of them.
We can distinguish between the fetchGroups(key)
and intoGroups(Function keyMapper)
methods that allow us to specify the field(s) representing the key, while the value is inferred from the SELECT
result as the Result<Record>
/List<Record>
and fetchGroups(key, value)
/intoGroups(Function keyMapper, Function valueMapper)
methods in which we specify the field(s) that represents the key and the value, respectively, which could be Result<Record>
, List<POJO>
, List<scalar>
, and more. The Records.intoGroups()
method without any arguments is only useful if you have a two-column ResultQuery
, and you want to map the first...